Submission #570577

#TimeUsernameProblemLanguageResultExecution timeMemory
570577MohammadAghilRemittance (JOI19_remittance)C++14
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> // #pragma GCC optimize ("Ofast,unroll-loops") // #pragma GCC target ("avx2") using namespace std; typedef long long ll; typedef pair<int, int> pp; #define er(args ...) cerr << __LINE__ << ": ", err(new istringstream(string(#args)), args), cerr << endl #define per(i,r,l) for(int i = (r); i >= (l); i--) #define rep(i,l,r) for(int i = (l); i < (r); i++) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() #define pb push_back #define ss second #define ff first void err(istringstream *iss){}template<typename T,typename ...Args> void err(istringstream *iss,const T &_val, const Args&...args){string _name;*iss>>_name;if(_name.back()==',')_name.pop_back();cerr<<_name<<" = "<<_val<<", ",err(iss,args...);} mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const ll mod = 1e9 + 7, maxn = 1e6 + 5, lg = 22, inf = ll(1e9) + 5; ll pw(ll a,ll b,ll md=mod){if(!b)return 1;ll k=pw(a,b>>1ll);return k*k%md*(b&1ll?a:1)%md;} int main(){ cin.tie(0) -> sync_with_stdio(0); int n; cin >> n; vector<int> c(n); set<pp> s; rep(i,0,n) { int a, b; cin >> a >> b; c[i] = a-b; s.insert({-c[i], i}); } while(-begin(s)->ff > 1){ auto[_, id] = *begin(s); s.erase(begin(s)); int t = (c[id]+1)>>1, nx = (id + 1)%n; c[id] &= 1; s.erase(pp(-c[nx], nx)); s.insert({-c[id], id}), c[nx] += t; s.insert({-c[nx], nx}); } cout << (begin(s)->ff == 0 && prev(end(s))->ff == 0? "Yes\n": "No\n"); return 0; }

Compilation message (stderr)

remittance.cpp: In function 'int main()':
remittance.cpp:31:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   31 |           auto[_, id] = *begin(s);
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...