add
This commit is contained in:
parent
8e0b266601
commit
164f041317
33
Codes/1976 A - Verify Password/1976A.cpp
Normal file
33
Codes/1976 A - Verify Password/1976A.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
#define ll long long
|
||||
#define endl '\n'
|
||||
ll pow(ll x,ll y,ll m=1e9+7){ll ans=1;x%=m;while(y){if(y&1)ans=(ans*x)%m;x=(x*x)%m;y>>=1;}return ans;}
|
||||
|
||||
void solve()
|
||||
{
|
||||
int n;
|
||||
string s;
|
||||
cin>>n>>s;
|
||||
for(int i=1; i<n; ++i)
|
||||
{
|
||||
if(s[i]<s[i-1])
|
||||
{
|
||||
cout<<"NO\n";
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout<<"YES\n";
|
||||
}
|
||||
|
||||
signed main()
|
||||
{
|
||||
ios_base::sync_with_stdio(false), cin.tie(nullptr);
|
||||
int TCS = 1;
|
||||
cin >> TCS;
|
||||
for (int TC = 1; TC <= TCS; ++TC)
|
||||
{
|
||||
// cout<<"Case "<<TC<<": ";
|
||||
solve();
|
||||
}
|
||||
}
|
36
Codes/1976 B - Increase Decrease Copy/1976B.cpp
Normal file
36
Codes/1976 B - Increase Decrease Copy/1976B.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
#define ll long long
|
||||
#define endl '\n'
|
||||
ll pow(ll x,ll y,ll m=1e9+7){ll ans=1;x%=m;while(y){if(y&1)ans=(ans*x)%m;x=(x*x)%m;y>>=1;}return ans;}
|
||||
|
||||
void solve()
|
||||
{
|
||||
ll n;
|
||||
cin>>n;
|
||||
vector<ll>a(n),b(n+1);
|
||||
for(auto &i: a) cin>>i;
|
||||
for(auto &i: b) cin>>i;
|
||||
ll ans=0, diff=1e18;
|
||||
for(ll i=0; i<n; ++i)
|
||||
{
|
||||
ans += abs(a[i]-b[i]);
|
||||
diff = min(diff, abs(b[n]-a[i]));
|
||||
diff = min(diff, abs(b[n]-b[i]));
|
||||
if(b[n]>=min(a[i],b[i]) && b[n]<=max(a[i],b[i]))
|
||||
diff = 0;
|
||||
}
|
||||
cout<<ans+1+diff<<endl;
|
||||
}
|
||||
|
||||
signed main()
|
||||
{
|
||||
ios_base::sync_with_stdio(false), cin.tie(nullptr);
|
||||
int TCS = 1;
|
||||
cin >> TCS;
|
||||
for (int TC = 1; TC <= TCS; ++TC)
|
||||
{
|
||||
// cout<<"Case "<<TC<<": ";
|
||||
solve();
|
||||
}
|
||||
}
|
26
Codes/1981 A - Turtle and Piggy Are Playing a Game/1981A.cpp
Normal file
26
Codes/1981 A - Turtle and Piggy Are Playing a Game/1981A.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
#define ll long long
|
||||
#define endl '\n'
|
||||
ll pow(ll x,ll y,ll m=1e9+7){ll ans=1;x%=m;while(y){if(y&1)ans=(ans*x)%m;x=(x*x)%m;y>>=1;}return ans;}
|
||||
|
||||
void solve()
|
||||
{
|
||||
int l,r;
|
||||
cin>>l>>r;
|
||||
if(r&1) r--;
|
||||
ll ans =log2(r);
|
||||
cout<<ans<<endl;
|
||||
}
|
||||
|
||||
signed main()
|
||||
{
|
||||
ios_base::sync_with_stdio(false), cin.tie(nullptr);
|
||||
int TCS = 1;
|
||||
cin >> TCS;
|
||||
for (int TC = 1; TC <= TCS; ++TC)
|
||||
{
|
||||
// cout<<"Case "<<TC<<": ";
|
||||
solve();
|
||||
}
|
||||
}
|
@ -326,6 +326,9 @@ This repository contains my solutions of Codeforces problems. They are in C++ la
|
||||
| 314 | 1971 D | Binary Cut | [Question](https://codeforces.com/problemset/problem/1971/D) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1971%20D%20-%20Binary%20Cut)
|
||||
| 315 | 1971 E | Find the Car | [Question](https://codeforces.com/problemset/problem/1971/E) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1971%20E%20-%20Find%20the%20Car)
|
||||
| 316 | 1971 F | Circle Perimeter | [Question](https://codeforces.com/problemset/problem/1971/F) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1971%20F%20-%20Circle%20Perimeter)
|
||||
| 317 | 1976 A | Verify Password | [Question](https://codeforces.com/problemset/problem/1976/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1976%20A%20-%20Verify%20Password)
|
||||
| 318 | 1976 B | Increase Decrease Copy | [Question](https://codeforces.com/problemset/problem/1976/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1976%20B%20-%20Increase%20Decrease%20Copy)
|
||||
| 319 | 1981 A | Turtle and Piggy Are Playing a Game | [Question](https://codeforces.com/problemset/problem/1981/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1981%20A%20-%20Turtle%20and%20Piggy%20Are%20Playing%20a%20Game)
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user