Skip to content

Commit

Permalink
Merge pull request #750 from thesuaveguy/main
Browse files Browse the repository at this point in the history
pr #423 added codechef LTIME110D solutions
  • Loading branch information
tanus786 authored Oct 29, 2022
2 parents 86ae847 + 0269028 commit e454772
Show file tree
Hide file tree
Showing 9 changed files with 331 additions and 0 deletions.
5 changes: 5 additions & 0 deletions LTIME110D/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"iostream": "cpp"
}
}
62 changes: 62 additions & 0 deletions LTIME110D/Consecutive XOR.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ll t;
cin >> t;
while (t--)
{
ll n;
cin >> n;
string a, b;
cin >> a;
cin >> b;
bool iszer = false;
char c = a[0];
bool isB = false;
for (int i = 0; i < b.size() - 1; i++)
{
if (b[i] == b[i + 1])
isB = true;
}
if (c == '0')
{
for (int i = 1; i < a.size(); i++)
{
if (a[i] == '1')
iszer = true;
}
if (iszer&isB)
cout << "YES" << endl;
else
{
if (a == b)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
else if (c == '1')
{
for (int i = 1; i < a.size(); i++)
{
if (a[i] == '0')
iszer = true;
}
if (isB)
{
cout << "YES" << endl;
}
else
{

if (a == b)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
}
return 0;
}
37 changes: 37 additions & 0 deletions LTIME110D/Easy Pronunciation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
ll t;
cin>>t;

while(t--)
{
ll n,count=0;
cin>>n;
string s;
vector<int>v;
cin>>s;
for (ll i = 0; i < n; i++)
{
if(s[i]=='a' || s[i]=='e' || s[i]=='i' || s[i]=='o' || s[i]=='u')
{
v.push_back(count);
count=0;
}
else
count++;
}
v.push_back(count);
sort(v.begin(),v.end());
if(v[v.size()-1]>=4)
cout<<"NO"<<endl;
else
cout<<"YES"<<endl;


}
return 0;
}
20 changes: 20 additions & 0 deletions LTIME110D/Interior Design.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ll t;
cin >> t;
while (t--)
{
ll a,b,c,d;
cin >> a>>b>>c>>d;
ll e=a+b;
ll f=c+d;
if(e>f)
cout<<f<<endl;
else
cout<<e<<endl;
}
return 0;
}
35 changes: 35 additions & 0 deletions LTIME110D/Largest Family.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
ll t;
cin >> t;

while (t--)
{
ll n;
cin >> n;
ll arr[n];
for (ll i = 0; i < n; i++)
{
cin >> arr[i];
}
ll count = 0;
ll sum = 0;
sort(arr, arr + n);
for (ll i = 0; i < n; i++)
{
sum += arr[i];
if (n - 1 >= sum)
{

count++;
}
}

cout << count << endl;
}
return 0;
}
52 changes: 52 additions & 0 deletions LTIME110D/Maximum Median Matching.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
ll t;
cin>>t;

while(t--)
{
ll n;
cin>>n;
ll arr[n];
ll brr[n];
for (ll i = 0; i < n; i++)
{
cin>>arr[i];
}
for (ll i = 0; i < n; i++)
{
cin>>brr[i];
}
sort(arr,arr+n);
sort(brr,brr+n);
vector<ll>v1;
vector<ll>v2;
for (ll i = (n-1)/2; i < n; i++)
{
v1.push_back(arr[i]);
}
for (ll i = (n-1)/2; i < n; i++)
{
v2.push_back(brr[i]);
}
sort(v1.begin(),v1.end());
sort(v2.begin(),v2.end(),greater<int>());

vector<ll>main;
for (ll i = 0; i < v1.size(); i++)
{
main.push_back(v1[i]+v2[i]);
}
sort(main.begin(),main.end());
cout<<main[0]<<endl;




}
return 0;
}
21 changes: 21 additions & 0 deletions LTIME110D/The Last Levels.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ll t;
cin >> t;
while (t--)
{
ll x,y,z;
cin >> x>>y>>z;
ll d;
if(x%3==0)
d=x/3 -1;
else
d=x/3;
cout<<((x*y)+(d*z))<<endl;

}
return 0;
}
16 changes: 16 additions & 0 deletions LTIME110D/True and False Paper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ll t;
cin >> t;
while (t--)
{
ll n,k;
cin >> n>>k;
cout<<n-k<<endl;

}
return 0;
}
83 changes: 83 additions & 0 deletions LTIME110D/Yet Another Palindrome Making Problem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t;
cin>>t;

while(t--)
{
ll n;
cin>>n;
string s;
ll flag=0;
cin>>s;
vector<pair<char,int>>v;
map<char,int>m;
for (ll i = 0; i < n; i++)
{
v.push_back({s[i],i+1});
m[s[i]]++;
}
sort(v.begin(),v.end());
for (auto it:m)
{
if(it.second%2!=0)
{
flag=1;
break;
}
}

ll odd=0;
ll even=0;
for (ll i = 0; i < n-1; i++)
{
if(v[i].first==v[i+1].first)
{
if(v[i].second%2==0)
even++;
else
odd++;
}
else
{
if(v[i].second%2==0)
even++;
else
odd++;
if(odd!=even)
{
flag=1;
break;
}
odd=0;
even=0;
}
if(i==n-2)
{
if(v[i+1].second%2==0)
even++;
else
odd++;
if(odd!=even)
{
flag=1;
break;
}
}
}

if(flag)
cout<<"NO"<<endl;
else
cout<<"YES"<<endl;


}
return 0;
}

0 comments on commit e454772

Please sign in to comment.