# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
486177 | 2021-11-10T17:24:53 Z | idas | Remittance (JOI19_remittance) | C++17 | 1 ms | 332 KB |
#include <bits/stdc++.h> #define FOR(i, begin, end) for(int i = (begin); i < (end); i++) #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr) #define TSTS int ttt; cin >> ttt; while(ttt--) solve() #define F first #define S second #define PB push_back #define MP make_pair #define sz(x) int((x).size()) using namespace std; typedef pair<int, int> pii; typedef pair<long long, long long> pll; typedef pair<long double, long double> pdd; typedef map<int, int> mii; typedef vector<int> vi; typedef long double ld; typedef long long ll; const int INF=1e9, MOD=1e9+7, mod=998244353; void setIO() { FAST_IO; } void setIO(string s) { FAST_IO; freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); } const int N=1e6+10; ll n, a[N], b[N]; int main() { setIO(); cin >> n; FOR(i, 0, n) { cin >> a[i] >> b[i]; } set<int> st; FOR(i, 0, n) { if(a[i]-b[i]>1) st.insert(i); } bool going=true; while(going){ going=false; for(auto x : st){ ll neg=a[x]-b[x]; neg/=2; a[x]-=neg*2; int nxt=(x+1)%n; a[nxt]+=neg; if(a[nxt]-b[nxt]>1){ st.insert(nxt); going=true; } if(a[x]-b[x]>1){ st.insert(x); going=true; } } } FOR(i, 0, n) { if(a[i]!=b[i]){ cout << "No"; return 0; } } cout << "Yes"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 320 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Incorrect | 1 ms | 204 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 320 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Incorrect | 1 ms | 204 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 320 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Incorrect | 1 ms | 204 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |