# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
162756 | 2019-11-09T15:59:04 Z | Swan | Remittance (JOI19_remittance) | C++14 | 2 ms | 380 KB |
#include <bits/stdc++.h> #define stop system("pause") #define INP freopen("input.txt","r",stdin) #define OUTP freopen("output.txt","w",stdout) #define double long double #define int long long using namespace std; typedef long long ll; vector<pair<int,int> > v; bool check(){ for(int i(0); i < v.size();i++){ if(v[i].first != v[i].second)return 0; } return 1; } bool solve(){ for(int i(0); i < v.size();i++){ int to = (i+1)%v.size(); int can = v[i].first-v[i].second; if(can <= 0)continue; can/=2; if(can == 0)continue; can = 1; v[to].first+=can; v[i].first-=2*can; //cerr << i+1 << ' ' << can << endl; return 1; } return 0; } main() { ios_base::sync_with_stdio(0); int n; cin >> n; for(int i(0); i < n;i++){ int a,b; cin >> a >> b; v.push_back({a,b}); } //cerr << '\n'; while(1){ bool f = solve(); if(!f)break; } if(!check())cout << "No"; else cout << "Yes"; return 0; } /* 3 1 3 3 4 6 3 7 9 3 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 380 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Incorrect | 2 ms | 376 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 380 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Incorrect | 2 ms | 376 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 380 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Incorrect | 2 ms | 376 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |