Submission #1111240

#TimeUsernameProblemLanguageResultExecution timeMemory
1111240mychecksedadRemittance (JOI19_remittance)C++17
100 / 100
173 ms32592 KiB
/* Author : Mychecksdead */ #include<bits/stdc++.h> using namespace std; #define ll long long int #define MOD (1000000000+7) #define MOD1 (998244353) #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n' #define ff first #define ss second #define pii pair<int,int> #define vi vector<int> const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30; int n, A[N], B[N], x[N], nx[N], C[N]; void solve(){ cin >> n; ll SA = 0, SB = 0; for(int i = 1; i <= n; ++i){ cin >> A[i] >> B[i]; x[i] = 0; SA += A[i]; SB += B[i]; } if(SB==0){ if(SA==0) cout << "Yes"; else cout << "No"; return; } if(SB > SA){ cout << "No"; return; } bool OK = 1; while(OK){ OK = 0; for(int i = 1; i <= n; ++i){ if(A[i] > B[i]){ ll t = (A[i]-B[i]+1)/2; A[i] -= 2*t; A[i==n?1:i+1] += t; if(t>0) OK = 1; } } } for(int i = 1; i <= n; ++i) if(A[i]!=B[i]) OK=1; if(OK){ cout << "No"; return; } cout << "Yes"; } int main(){ cin.tie(0); ios::sync_with_stdio(0); int tt = 1, aa; // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); while(tt--){ solve(); en; } cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n"; return 0; }

Compilation message (stderr)

remittance.cpp: In function 'int main()':
remittance.cpp:60:15: warning: unused variable 'aa' [-Wunused-variable]
   60 |   int tt = 1, aa;
      |               ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...