# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
321624 | 2020-11-12T23:34:10 Z | Lawliet | Remittance (JOI19_remittance) | C++17 | 1 ms | 384 KB |
#include <bits/stdc++.h> using namespace std; typedef long long int lli; const int MAXN = 1000010; const lli INF = 1000000000000000000LL; int n; lli diff[MAXN]; void impossible() { printf("No\n"); exit(0); } int main() { scanf("%d",&n); for(int i = 1 ; i <= n ; i++) { int a, b; scanf("%d %d",&a,&b); diff[i] = a - b; } lli xCur = 0; lli xCross = 0; for(int i = 1 ; i < n ; i++) { lli xNext = diff[i] + xCur; if( xNext%2 == 1 ) { if( i >= 62 ) impossible(); xCur++; xNext++; xCross += (1LL << (i - 1)); } if( xNext < 0 ) { if( i >= 62 ) impossible(); lli p = (1LL << (i - 1)); if( -xNext > INF/p ) impossible(); xNext = 0; xCross += -xNext*p; } xCur = xNext/2; if( xCross >= INF ) impossible(); } lli s = diff[n] + xCur; if( s%2 == 0 && s/2 == xCross ) printf("Yes\n"); else impossible(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 0 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 0 ms | 364 KB | Output is correct |
5 | Incorrect | 1 ms | 384 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 0 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 0 ms | 364 KB | Output is correct |
5 | Incorrect | 1 ms | 384 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 0 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 0 ms | 364 KB | Output is correct |
5 | Incorrect | 1 ms | 384 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |