Submission #683066

#TimeUsernameProblemLanguageResultExecution timeMemory
683066tht2005Remittance (JOI19_remittance)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; #define N 1000006 int a[N], b[N], tmp[N]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; for(int i = 0; i < n; ++i) { cin >> a[i] >> b[i]; } for(int t = 1; t < 1 << n; ++t) { bool ok = 1; for(int i = 0; i < n && ok; ++i) { if(!(t >> i & 1)) { continue; } vector<int> pos(1, i); for(int j = (i + 1) % n; !(t >> j & 1); j = (j + 1) % n) { pos.push_back(j); } for(int j : pos) { tmp[j] = a[j]; } for(int j = 0; j < (int)pos.size(); ++j) { if(tmp[pos[j]] < b[pos[j]] || ((tmp[pos[j]] - b[pos[j]]) & 1)) { ok = 0; break; } if(b[pos[j]] != tmp[pos[j]] && j + 1 == (int)pos.size()) { ok = 0; break; } if(j + 1 < (int)pos.size()) { tmp[pos[j + 1]] += (tmp[pos[j]] - b[pos[j]]) >> 1; } } } if(ok) { cout << "Yes"; return 0; } } cout << "No"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...