# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
570357 | 2022-05-29T10:29:33 Z | urd05 | 송금 (JOI19_remittance) | C++17 | 1 ms | 360 KB |
#include <bits/stdc++.h> using namespace std; int n; long long c[1000001]; long long arr[1000001]; //비트 저장 long long value[1000001]; long long money[1000001]; bool vis[1000001]; int main() { scanf("%d",&n); for(int i=1;i<=n;i++) { int a,b; scanf("%d %d",&a,&b); money[i]=a; c[i]=b-a; } arr[0]=(c[n]&1); long long val=(c[n]>>1); for(int i=1;i<n;i++) { val+=c[i]; arr[i]=(val&1); val=(val>>1); } long long mok=val; long long pr=val; arr[0]+=val; while (pr!=0) { long long now=0; for(int i=0;i<n;i++) { if (i==n-1) { now+=(arr[i]>>1); } else { arr[i+1]+=(arr[i]>>1); } arr[i]=(arr[i]&1); } pr=now; mok+=now; arr[0]+=now; } bool flag=true; for(int i=1;i<n;i++) { if (arr[i]!=arr[i-1]) { flag=false; break; } } if (!flag) { printf("No"); return 0; } if (arr[0]==1) { mok++; } if (mok>0) { printf("No"); return 0; } long long x=-mok; value[n]=x; for(int i=n-1;i>0;i--) { x=2*x+c[i]; value[i]=x; if (x<0) { printf("No"); return 0; } } for(int i=1;i<=n;i++) { if (2*value[i]<=money[i]) { printf("Yes"); return 0; } } printf("No"); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 360 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Incorrect | 1 ms | 340 KB | Output isn't correct |
21 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 360 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Incorrect | 1 ms | 340 KB | Output isn't correct |
21 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 360 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Incorrect | 1 ms | 340 KB | Output isn't correct |
21 | Halted | 0 ms | 0 KB | - |