#include<bits/stdc++.h> // #define SINGLE_INPUT #define ull unsigned long long #define ll long long #define N 500005 #define MOD 998244353 usingnamespace std;
random_device seed; ranlux48 engine(seed()); intrandom(int l, int r){ uniform_int_distribution<> distrib(l, r); returndistrib(engine); } template<classt,classu> ostream& operator<<(ostream& os,const pair<t,u>& p) { return os<<'['<<p.first<<", "<<p.second<<']'; } template<classt> ostream& operator<<(ostream& os,const vector<t>& v) { os<<'['; int s = 1; for(auto e:v) { if (s) s = 0; else os << ", "; os << e; } return os<<']'; } template<classt,classu> ostream& operator<<(ostream& os,const map<t,u>& mp){ os<<'{'; int s = 1; for(auto [x,y]:mp) { if (s) s = 0; else os << ", "; os<<x<<": "<<y; } return os<<'}'; }
voidsol(){ int x, y; cin >> x >> y; if (y<-1) { cout << "NO\n"; } else { cout << "YES\n"; } }
#include<bits/stdc++.h> // #define SINGLE_INPUT #define ull unsigned long long #define ll long long #define N 500005 #define MOD 998244353 usingnamespace std;
random_device seed; ranlux48 engine(seed()); intrandom(int l, int r){ uniform_int_distribution<> distrib(l, r); returndistrib(engine); } template<classt,classu> ostream& operator<<(ostream& os,const pair<t,u>& p) { return os<<'['<<p.first<<", "<<p.second<<']'; } template<classt> ostream& operator<<(ostream& os,const vector<t>& v) { os<<'['; int s = 1; for(auto e:v) { if (s) s = 0; else os << ", "; os << e; } return os<<']'; } template<classt,classu> ostream& operator<<(ostream& os,const map<t,u>& mp){ os<<'{'; int s = 1; for(auto [x,y]:mp) { if (s) s = 0; else os << ", "; os<<x<<": "<<y; } return os<<'}'; }
voidsol(){ string s, t; cin >> s >> t; int m = s.length(), n = t.length(); int ans = n+m; for (int i=0; i<n; i++) { int p = 0, j; for (j=i; j<n; j++,p++) { while (p<m && s[p] != t[j]) p++; if (p == m) { break; } } // cout << i << " " << j << endl; ans = min(ans, n+m-(j-i)); } cout << ans << "\n"; }
#include<bits/stdc++.h> // #define SINGLE_INPUT #define ull unsigned long long #define ll long long #define N 500005 #define MOD 998244353 usingnamespace std;
random_device seed; ranlux48 engine(seed()); intrandom(int l, int r){ uniform_int_distribution<> distrib(l, r); returndistrib(engine); } template<classt,classu> ostream& operator<<(ostream& os,const pair<t,u>& p) { return os<<'['<<p.first<<", "<<p.second<<']'; } template<classt> ostream& operator<<(ostream& os,const vector<t>& v) { os<<'['; int s = 1; for(auto e:v) { if (s) s = 0; else os << ", "; os << e; } return os<<']'; } template<classt,classu> ostream& operator<<(ostream& os,const map<t,u>& mp){ os<<'{'; int s = 1; for(auto [x,y]:mp) { if (s) s = 0; else os << ", "; os<<x<<": "<<y; } return os<<'}'; }
voidsol(){ int n; cin >> n; vector<int> a(n), b(n); for (auto& i:a) cin >> i; for (auto& i:b) cin >> i; int l = 0, r = 0, x = 0, y = 0; for (int i=0; i<n; i++) { if (a[i] > b[i]) { x+=a[i]; } elseif (a[i] < b[i]) { y+=b[i]; } else { if (a[i]<0) l--; if (a[i]>0) r++; } } int ans = -1e9; for (int i=l; i<=r; i++) { ans = max(ans, min(x+i, y+(l+r-i))); } cout << ans << "\n"; }
#include<bits/stdc++.h> #define SINGLE_INPUT #define ull unsigned long long #define ll long long #define N 500005 #define MOD 998244353 usingnamespace std;
random_device seed; ranlux48 engine(seed()); intrandom(int l, int r){ uniform_int_distribution<> distrib(l, r); returndistrib(engine); } template<classt,classu> ostream& operator<<(ostream& os,const pair<t,u>& p) { return os<<'['<<p.first<<", "<<p.second<<']'; } template<classt> ostream& operator<<(ostream& os,const vector<t>& v) { os<<'['; int s = 1; for(auto e:v) { if (s) s = 0; else os << ", "; os << e; } return os<<']'; } template<classt,classu> ostream& operator<<(ostream& os,const map<t,u>& mp){ os<<'{'; int s = 1; for(auto [x,y]:mp) { if (s) s = 0; else os << ", "; os<<x<<": "<<y; } return os<<'}'; }
voidsol(){ int n, m; cin >> n >> m; vector<ll> a(n), b(n), c(m); for (auto& i:a) cin >> i; for (auto& i:b) cin >> i; for (auto& i:c) cin >> i; int mx = *max_element(a.begin(), a.end()); vector<ll> f(mx+1, 1e9), v(mx+1); for (int i=0; i<n; i++) { f[a[i]] = min(f[a[i]], a[i]-b[i]); } for (int i=1; i<=mx; i++) { f[i] = min(f[i], f[i-1]); } for (int i=1; i<=mx; i++) { if (i>=f[i]) v[i] = v[i-f[i]]+2; } // cout << a << b << c << f << v << endl; ll ans = 0; for (int i:c) { if (i > mx) { // i - k*f[mx] <= mx // ceil( (i-mx)/f[mx] ) <=k ll k = (i-mx+f[mx]-1)/f[mx]; ans += 2*k; i -= k*f[mx]; } ans += v[i]; } cout << ans << '\n'; }