Submission #19575443
Source Code Expand
Copy
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int INF = 1e9; const long long INFLL = 1e18; using ll = long long; int main(){ int n; cin >> n; vector<ll> a(n), b(n); ll suma = 0, sumb = 0; for(int i = 0; i < n; i++) { cin >> a[i]; suma += a[i]; } for(int i = 0; i < n; i++) { cin >> b[i]; sumb += b[i]; } ll cnta = sumb - suma; ll cntb = sumb - suma; string ans = "Yes"; for(int i = 0; i < n - 1; i++){ if(a[i] > b[i]){ cntb -= a[i] - b[i]; }else{ if((b[i] - a[i]) % 2 == 0){ cnta -= (b[i] - a[i]) / 2; }else{ cnta -= (b[i] - a[i] + 1) / 2; cntb -= 1; } } } if(cnta < 0 || cntb < 0) ans = "No"; else if(a[n-1] + 2 * cnta != b[n-1] + cntb) ans = "No"; cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Two Arrays |
User | odango3 |
Language | C++ (GCC 9.2.1) |
Score | 300 |
Code Size | 874 Byte |
Status | AC |
Exec Time | 21 ms |
Memory | 3736 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt, 1_026.txt, 1_027.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 8 ms | 3504 KB |
0_001.txt | AC | 2 ms | 3436 KB |
0_002.txt | AC | 2 ms | 3476 KB |
1_003.txt | AC | 16 ms | 3636 KB |
1_004.txt | AC | 13 ms | 3676 KB |
1_005.txt | AC | 16 ms | 3616 KB |
1_006.txt | AC | 14 ms | 3660 KB |
1_007.txt | AC | 17 ms | 3608 KB |
1_008.txt | AC | 13 ms | 3648 KB |
1_009.txt | AC | 14 ms | 3644 KB |
1_010.txt | AC | 14 ms | 3608 KB |
1_011.txt | AC | 14 ms | 3608 KB |
1_012.txt | AC | 21 ms | 3612 KB |
1_013.txt | AC | 16 ms | 3676 KB |
1_014.txt | AC | 14 ms | 3544 KB |
1_015.txt | AC | 13 ms | 3608 KB |
1_016.txt | AC | 15 ms | 3644 KB |
1_017.txt | AC | 14 ms | 3708 KB |
1_018.txt | AC | 15 ms | 3648 KB |
1_019.txt | AC | 18 ms | 3712 KB |
1_020.txt | AC | 13 ms | 3644 KB |
1_021.txt | AC | 13 ms | 3600 KB |
1_022.txt | AC | 15 ms | 3708 KB |
1_023.txt | AC | 18 ms | 3736 KB |
1_024.txt | AC | 19 ms | 3616 KB |
1_025.txt | AC | 13 ms | 3648 KB |
1_026.txt | AC | 13 ms | 3652 KB |
1_027.txt | AC | 17 ms | 3596 KB |