Submission #519132

# Submission time Handle Problem Language Result Execution time Memory
519132 2022-01-25T17:48:58 Z cig32 Remittance (JOI19_remittance) C++17
0 / 100
3 ms 312 KB
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
mt19937_64 rng((int)std::chrono::steady_clock::now().time_since_epoch().count());
const int MAXN = 3e5 + 10;
const int MOD = 1e9 + 7;
#define int long long
void solve(int tc) {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for(int i=0; i<n; i++) cin >> a[i] >> b[i];
  for(int i=0; i<300000; i++) {
    for(int j=0; j<n; j++) {
      if(a[j] > b[j]) {
        int c = (a[j] - b[j]) / 2;
        a[j] -= c * 2;
        a[(j+1) % n] += c;
      }
    }
  }
  for(int i=0; i<n; i++) {
    if(a[i] != b[i]) {
      cout << "No\n"; return;
    }
  }
  cout << "Yes\n";
}
 
int32_t main(){
  ios::sync_with_stdio(0); cin.tie(0);
  int t = 1; //cin >> t;
  for(int i=1; i<=t; i++) solve(i);
} 
# Verdict Execution time Memory Grader output
1 Correct 3 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 308 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 2 ms 204 KB Output is correct
6 Correct 3 ms 204 KB Output is correct
7 Correct 3 ms 312 KB Output is correct
8 Incorrect 3 ms 204 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 308 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 2 ms 204 KB Output is correct
6 Correct 3 ms 204 KB Output is correct
7 Correct 3 ms 312 KB Output is correct
8 Incorrect 3 ms 204 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 308 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 2 ms 204 KB Output is correct
6 Correct 3 ms 204 KB Output is correct
7 Correct 3 ms 312 KB Output is correct
8 Incorrect 3 ms 204 KB Output isn't correct
9 Halted 0 ms 0 KB -