Submission #519656

# Submission time Handle Problem Language Result Execution time Memory
519656 2022-01-27T00:00:42 Z cig32 Remittance (JOI19_remittance) C++17
55 / 100
1000 ms 35172 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
int rnd(int x, int y) {
  int u = uniform_int_distribution<int>(x, y)(rng); return u;
}
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<5e6; i++) {
    for(int j=0; j<n; j++) {
      if(a[j] > b[j]) {
        int c = (a[j] - b[j] + 1) / 2;
        c = max(c, 0ll);
        c = min(c, a[j] / 2);
        a[j] -= 2 * c;
        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 60 ms 204 KB Output is correct
2 Correct 17 ms 308 KB Output is correct
3 Correct 15 ms 312 KB Output is correct
4 Correct 22 ms 312 KB Output is correct
5 Correct 35 ms 292 KB Output is correct
6 Correct 41 ms 204 KB Output is correct
7 Correct 42 ms 204 KB Output is correct
8 Correct 13 ms 308 KB Output is correct
9 Correct 35 ms 204 KB Output is correct
10 Correct 40 ms 204 KB Output is correct
11 Correct 43 ms 204 KB Output is correct
12 Correct 14 ms 300 KB Output is correct
13 Correct 29 ms 300 KB Output is correct
14 Correct 32 ms 204 KB Output is correct
15 Correct 44 ms 308 KB Output is correct
16 Correct 27 ms 204 KB Output is correct
17 Correct 35 ms 292 KB Output is correct
18 Correct 40 ms 204 KB Output is correct
19 Correct 43 ms 204 KB Output is correct
20 Correct 176 ms 292 KB Output is correct
21 Correct 169 ms 288 KB Output is correct
22 Correct 53 ms 288 KB Output is correct
23 Correct 143 ms 292 KB Output is correct
24 Correct 44 ms 300 KB Output is correct
25 Correct 41 ms 204 KB Output is correct
26 Correct 183 ms 204 KB Output is correct
27 Correct 43 ms 204 KB Output is correct
28 Correct 42 ms 204 KB Output is correct
29 Correct 41 ms 204 KB Output is correct
30 Correct 43 ms 288 KB Output is correct
31 Correct 172 ms 292 KB Output is correct
32 Correct 48 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 60 ms 204 KB Output is correct
2 Correct 17 ms 308 KB Output is correct
3 Correct 15 ms 312 KB Output is correct
4 Correct 22 ms 312 KB Output is correct
5 Correct 35 ms 292 KB Output is correct
6 Correct 41 ms 204 KB Output is correct
7 Correct 42 ms 204 KB Output is correct
8 Correct 13 ms 308 KB Output is correct
9 Correct 35 ms 204 KB Output is correct
10 Correct 40 ms 204 KB Output is correct
11 Correct 43 ms 204 KB Output is correct
12 Correct 14 ms 300 KB Output is correct
13 Correct 29 ms 300 KB Output is correct
14 Correct 32 ms 204 KB Output is correct
15 Correct 44 ms 308 KB Output is correct
16 Correct 27 ms 204 KB Output is correct
17 Correct 35 ms 292 KB Output is correct
18 Correct 40 ms 204 KB Output is correct
19 Correct 43 ms 204 KB Output is correct
20 Correct 176 ms 292 KB Output is correct
21 Correct 169 ms 288 KB Output is correct
22 Correct 53 ms 288 KB Output is correct
23 Correct 143 ms 292 KB Output is correct
24 Correct 44 ms 300 KB Output is correct
25 Correct 41 ms 204 KB Output is correct
26 Correct 183 ms 204 KB Output is correct
27 Correct 43 ms 204 KB Output is correct
28 Correct 42 ms 204 KB Output is correct
29 Correct 41 ms 204 KB Output is correct
30 Correct 43 ms 288 KB Output is correct
31 Correct 172 ms 292 KB Output is correct
32 Correct 48 ms 204 KB Output is correct
33 Correct 142 ms 292 KB Output is correct
34 Correct 148 ms 288 KB Output is correct
35 Correct 147 ms 292 KB Output is correct
36 Correct 14 ms 204 KB Output is correct
37 Correct 142 ms 288 KB Output is correct
38 Correct 14 ms 304 KB Output is correct
39 Correct 32 ms 204 KB Output is correct
40 Correct 173 ms 292 KB Output is correct
41 Correct 146 ms 204 KB Output is correct
42 Correct 14 ms 204 KB Output is correct
43 Correct 32 ms 292 KB Output is correct
44 Correct 172 ms 288 KB Output is correct
45 Correct 160 ms 292 KB Output is correct
46 Correct 13 ms 204 KB Output is correct
47 Correct 34 ms 204 KB Output is correct
48 Correct 144 ms 300 KB Output is correct
49 Correct 149 ms 292 KB Output is correct
50 Correct 50 ms 204 KB Output is correct
51 Correct 486 ms 288 KB Output is correct
52 Correct 30 ms 292 KB Output is correct
53 Correct 473 ms 292 KB Output is correct
54 Correct 142 ms 292 KB Output is correct
55 Correct 156 ms 288 KB Output is correct
56 Correct 495 ms 296 KB Output is correct
57 Correct 151 ms 204 KB Output is correct
58 Correct 194 ms 296 KB Output is correct
59 Correct 143 ms 204 KB Output is correct
60 Correct 143 ms 296 KB Output is correct
61 Correct 501 ms 204 KB Output is correct
62 Correct 144 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 60 ms 204 KB Output is correct
2 Correct 17 ms 308 KB Output is correct
3 Correct 15 ms 312 KB Output is correct
4 Correct 22 ms 312 KB Output is correct
5 Correct 35 ms 292 KB Output is correct
6 Correct 41 ms 204 KB Output is correct
7 Correct 42 ms 204 KB Output is correct
8 Correct 13 ms 308 KB Output is correct
9 Correct 35 ms 204 KB Output is correct
10 Correct 40 ms 204 KB Output is correct
11 Correct 43 ms 204 KB Output is correct
12 Correct 14 ms 300 KB Output is correct
13 Correct 29 ms 300 KB Output is correct
14 Correct 32 ms 204 KB Output is correct
15 Correct 44 ms 308 KB Output is correct
16 Correct 27 ms 204 KB Output is correct
17 Correct 35 ms 292 KB Output is correct
18 Correct 40 ms 204 KB Output is correct
19 Correct 43 ms 204 KB Output is correct
20 Correct 176 ms 292 KB Output is correct
21 Correct 169 ms 288 KB Output is correct
22 Correct 53 ms 288 KB Output is correct
23 Correct 143 ms 292 KB Output is correct
24 Correct 44 ms 300 KB Output is correct
25 Correct 41 ms 204 KB Output is correct
26 Correct 183 ms 204 KB Output is correct
27 Correct 43 ms 204 KB Output is correct
28 Correct 42 ms 204 KB Output is correct
29 Correct 41 ms 204 KB Output is correct
30 Correct 43 ms 288 KB Output is correct
31 Correct 172 ms 292 KB Output is correct
32 Correct 48 ms 204 KB Output is correct
33 Correct 142 ms 292 KB Output is correct
34 Correct 148 ms 288 KB Output is correct
35 Correct 147 ms 292 KB Output is correct
36 Correct 14 ms 204 KB Output is correct
37 Correct 142 ms 288 KB Output is correct
38 Correct 14 ms 304 KB Output is correct
39 Correct 32 ms 204 KB Output is correct
40 Correct 173 ms 292 KB Output is correct
41 Correct 146 ms 204 KB Output is correct
42 Correct 14 ms 204 KB Output is correct
43 Correct 32 ms 292 KB Output is correct
44 Correct 172 ms 288 KB Output is correct
45 Correct 160 ms 292 KB Output is correct
46 Correct 13 ms 204 KB Output is correct
47 Correct 34 ms 204 KB Output is correct
48 Correct 144 ms 300 KB Output is correct
49 Correct 149 ms 292 KB Output is correct
50 Correct 50 ms 204 KB Output is correct
51 Correct 486 ms 288 KB Output is correct
52 Correct 30 ms 292 KB Output is correct
53 Correct 473 ms 292 KB Output is correct
54 Correct 142 ms 292 KB Output is correct
55 Correct 156 ms 288 KB Output is correct
56 Correct 495 ms 296 KB Output is correct
57 Correct 151 ms 204 KB Output is correct
58 Correct 194 ms 296 KB Output is correct
59 Correct 143 ms 204 KB Output is correct
60 Correct 143 ms 296 KB Output is correct
61 Correct 501 ms 204 KB Output is correct
62 Correct 144 ms 296 KB Output is correct
63 Execution timed out 1096 ms 35172 KB Time limit exceeded
64 Halted 0 ms 0 KB -