added 1989 A,B,C
This commit is contained in:
parent
fd87dcb57c
commit
54ebda7aae
46
Codes/1989 A - Catch the Coin/1989A.cpp
Normal file
46
Codes/1989 A - Catch the Coin/1989A.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
#ifdef ONLINE_JUDGE
|
||||
#define dbg(...)
|
||||
#else
|
||||
#include "Assets/debug.h"
|
||||
#endif
|
||||
#define int long long
|
||||
#define ll long long
|
||||
#define endl '\n'
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define ins insert
|
||||
#define pb push_back
|
||||
#define ppb pop_back
|
||||
#define sz(x) (int)(x).size()
|
||||
#define all(x) x.begin(), x.end()
|
||||
#define rep(i,a,b) for(int i=a; i<b; ++i)
|
||||
#define rrep(i,a,b) for(int i=a; i>=b; --i)
|
||||
#define yn(f) f? cout<<"YES\n":cout<<"NO\n"
|
||||
#define FAST (ios_base::sync_with_stdio(false), cin.tie(nullptr));
|
||||
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;
|
||||
cin>>n;
|
||||
rep(i,0,n)
|
||||
{
|
||||
int x,y;
|
||||
cin>>x>>y;
|
||||
yn(y>=-1);
|
||||
}
|
||||
}
|
||||
|
||||
signed main()
|
||||
{
|
||||
FAST;
|
||||
int TCS = 1;
|
||||
// cin >> TCS;
|
||||
for (int TC = 1; TC <= TCS; ++TC)
|
||||
{
|
||||
// cout<<"Case "<<TC<<": ";
|
||||
solve();
|
||||
}
|
||||
}
|
52
Codes/1989 B - Substring and Subsequence/1989B.cpp
Normal file
52
Codes/1989 B - Substring and Subsequence/1989B.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
#ifdef ONLINE_JUDGE
|
||||
#define dbg(...)
|
||||
#else
|
||||
#include "Assets/debug.h"
|
||||
#endif
|
||||
#define int long long
|
||||
#define ll long long
|
||||
#define endl '\n'
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define ins insert
|
||||
#define pb push_back
|
||||
#define ppb pop_back
|
||||
#define sz(x) (int)(x).size()
|
||||
#define all(x) x.begin(), x.end()
|
||||
#define rep(i,a,b) for(int i=a; i<b; ++i)
|
||||
#define rrep(i,a,b) for(int i=a; i>=b; --i)
|
||||
#define yn(f) f? cout<<"YES\n":cout<<"NO\n"
|
||||
#define FAST (ios_base::sync_with_stdio(false), cin.tie(nullptr));
|
||||
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()
|
||||
{
|
||||
string a,b;
|
||||
cin>>a>>b;
|
||||
int n=a.length(), m=b.length();
|
||||
int mn=m+n;
|
||||
rep(i,0,m)
|
||||
{
|
||||
int k=i;
|
||||
rep(j,0,n)
|
||||
{
|
||||
if(k<m && a[j]==b[k]) k++;
|
||||
}
|
||||
mn = min(mn, n+m-k+i);
|
||||
}
|
||||
cout<<mn<<endl;
|
||||
}
|
||||
|
||||
signed main()
|
||||
{
|
||||
FAST;
|
||||
int TCS = 1;
|
||||
cin >> TCS;
|
||||
for (int TC = 1; TC <= TCS; ++TC)
|
||||
{
|
||||
// cout<<"Case "<<TC<<": ";
|
||||
solve();
|
||||
}
|
||||
}
|
62
Codes/1989 C - Two Movies/1989C.cpp
Normal file
62
Codes/1989 C - Two Movies/1989C.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
#ifdef ONLINE_JUDGE
|
||||
#define dbg(...)
|
||||
#else
|
||||
#include "Assets/debug.h"
|
||||
#endif
|
||||
#define int long long
|
||||
#define ll long long
|
||||
#define endl '\n'
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define ins insert
|
||||
#define pb push_back
|
||||
#define ppb pop_back
|
||||
#define sz(x) (int)(x).size()
|
||||
#define all(x) x.begin(), x.end()
|
||||
#define rep(i,a,b) for(int i=a; i<b; ++i)
|
||||
#define rrep(i,a,b) for(int i=a; i>=b; --i)
|
||||
#define yn(f) f? cout<<"YES\n":cout<<"NO\n"
|
||||
#define FAST (ios_base::sync_with_stdio(false), cin.tie(nullptr));
|
||||
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;
|
||||
cin>>n;
|
||||
vector<int>a(n),b(n);
|
||||
for(auto &i:a) cin>>i;
|
||||
for(auto &i:b) cin>>i;
|
||||
int p=0, m=0, x=0, y=0;
|
||||
rep(i,0,n)
|
||||
{
|
||||
if(a[i]==1 && b[i]==1) p++;
|
||||
else if(a[i]==-1 && b[i]==-1) m++;
|
||||
else if(a[i]>b[i]) x+=a[i];
|
||||
else if(a[i]<=b[i]) y+=b[i];
|
||||
}
|
||||
while(p--)
|
||||
{
|
||||
if(x>y) y++;
|
||||
else x++;
|
||||
}
|
||||
while(m--)
|
||||
{
|
||||
if(x>y) x--;
|
||||
else y--;
|
||||
}
|
||||
cout<<min(x,y)<<endl;
|
||||
}
|
||||
|
||||
signed main()
|
||||
{
|
||||
FAST;
|
||||
int TCS = 1;
|
||||
cin >> TCS;
|
||||
for (int TC = 1; TC <= TCS; ++TC)
|
||||
{
|
||||
// cout<<"Case "<<TC<<": ";
|
||||
solve();
|
||||
}
|
||||
}
|
@ -358,6 +358,9 @@ This repository contains my solutions of Codeforces problems. They are in C++ la
|
||||
| 346 | 1986 C | Update Queries | [Question](https://codeforces.com/problemset/problem/1986/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1986%20C%20-%20Update%20Queries)
|
||||
| 347 | 1986 D | Mathematical Problem | [Question](https://codeforces.com/problemset/problem/1986/D) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1986%20D%20-%20Mathematical%20Problem)
|
||||
| 348 | 1986 E | Beautiful Array | [Question](https://codeforces.com/problemset/problem/1986/E) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1986%20E%20-%20Beautiful%20Array)
|
||||
| 349 | 1989 A | Catch the Coin | [Question](https://codeforces.com/problemset/problem/1989/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1989%20A%20-%20Catch%20the%20Coin)
|
||||
| 350 | 1989 B | Substring and Subsequence | [Question](https://codeforces.com/problemset/problem/1989/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1989%20B%20-%20Substring%20and%20Subsequence)
|
||||
| 351 | 1989 C | Two Movies | [Question](https://codeforces.com/problemset/problem/1989/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1989%20C%20-%20Two%20Movies)
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user