# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
428216 | 2021-06-15T08:52:44 Z | Amylopectin | Remittance (JOI19_remittance) | C++14 | 1 ms | 304 KB |
#include <iostream> #include <stdio.h> using namespace std; const long long mxn = 4e6 + 10,mxi = 1e10 + 10; long long be[mxn] = {},af[mxn] = {},tw[mxn] = {}; long long fima(long long l,long long r) { if(l > r) return l; return r; } int main() { long long i,j,n,m,cma = 0,fr = 0,cva = 0,of = 0,ba,ru; scanf("%lld",&n); for(i=0; i<n; i++) { scanf("%lld %lld",&be[i],&af[i]); cma = fima(cma,be[i] - af[i]); } tw[0] = 1; for(i=1; i<40; i++) { tw[i] = tw[i-1] * 2; // if(tw[i] > cma) // { // break; // } } ba = n-1; for(i=0; i<n; i++) { cva += be[i] - af[i]; ru = ba; while((cva < 0 || cva%2 != 0) && ba > i) { ru = ba; while(((be[ru] - af[ru])%2 + 2) % 2 == 1 && ru > i+1) { ru --; } if(((be[ru] - af[ru])%2 + 2) % 2 == 1) { of = 1; break; } for(j=ru; j<ba; j++) { if((be[j] - af[j]) % 2 != 0) { of = 1; break; } be[j+1] += (be[j] - af[j]) / 2; be[j] = af[j]; } if(i + n - ba > 38 || of == 1) { of = 1; break; } if((be[ba] - af[ba]) % tw[i+n-ba] == 0) { cva += (be[ba] - af[ba]) / tw[i+n-ba]; ba = ru-1; } else { of = 1; break; } } if(ba == i || of == 1 || cva % 2 != 0) { break; } cva /= 2; } // for(i=n-1; i>=0; i--) // { // cva += be[i] - af[i]; // while(cva > 0 && fr < i) // { // if(n-i+fr > 35) // { // of = 1; // break; // } // cva += (be[fr] - af[fr]) * tw[n-i + fr]; // fr ++; // } // if(fr == i || of == 1) // { // break; // } // cva *= 2; // if(cva > mxi) // { // of = 1; // break; // } // } if(cva == 0 && of == 0) { printf("Yes\n"); } else { printf("No\n"); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 304 KB | Output is correct |
6 | Correct | 1 ms | 204 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 | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 304 KB | Output is correct |
6 | Correct | 1 ms | 204 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 | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 304 KB | Output is correct |
6 | Correct | 1 ms | 204 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 | - |