Submission #3587258
Source Code Expand
#include<iostream> #include<string> #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> #include<vector> #include<functional> #include<iomanip> #include<queue> #include<cassert> #include<tuple> #include<set> #include<map> #include<list> #include<bitset> #include<utility> #include<numeric> #define pb push_back #define mp make_pair #define all(a) (a).begin(),(a).end() #define dwn(a) (a).begin(),(a).end(), greater<int>() #define rep(i, m) for (int i = 0; i < m; i++) #define REP(i, n, m) for (int i = n; i < m; i++) #define V vector<int> #define VV vector<V> #define VVV vector<VV> using namespace std; typedef long long ll; typedef pair<int, int> P; const int dx[4] = { 1, 0, -1, 0 }; const int dy[4] = { 0, 1, 0, -1 }; const int INF = (int)1e9; const ll inf = (ll)1e18; const ll MOD{ (ll)1e9 + 7 }; const long double EPS = 1e-10; int main() { int n; cin >> n; vector<ll> a(n), b(n); rep(i, n) { cin >> a[i]; } rep(i, n) { cin >> b[i]; } ll cnt = 0; rep(i, n) { //a[i]>b[i]のときは実質的にa[i]に1足せる if (a[i] > b[i]) { ll k = a[i] - b[i]; b[i] += k; //先にbに1を足す操作 cnt += k; } } rep(i, n) { if (a[i] < b[i]) { ll k = (b[i] - a[i]) / 2; a[i] += 2 * k; cnt -= k; //後でaに1を足す操作 if (a[i] < b[i]) { a[i] += 2; b[i] += 1; } } } //b操作以上にa操作が行えるか //a[i]>b[i]が作れるならa[i]==b[i]に出来るため if (cnt <= 0) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Two Arrays |
User | tako_39 |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1633 Byte |
Status | AC |
Exec Time | 9 ms |
Memory | 384 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 | 1 ms | 256 KB |
0_001.txt | AC | 1 ms | 256 KB |
0_002.txt | AC | 1 ms | 256 KB |
1_003.txt | AC | 7 ms | 384 KB |
1_004.txt | AC | 7 ms | 384 KB |
1_005.txt | AC | 9 ms | 384 KB |
1_006.txt | AC | 9 ms | 384 KB |
1_007.txt | AC | 9 ms | 384 KB |
1_008.txt | AC | 9 ms | 384 KB |
1_009.txt | AC | 9 ms | 384 KB |
1_010.txt | AC | 9 ms | 384 KB |
1_011.txt | AC | 9 ms | 384 KB |
1_012.txt | AC | 9 ms | 384 KB |
1_013.txt | AC | 9 ms | 384 KB |
1_014.txt | AC | 9 ms | 384 KB |
1_015.txt | AC | 9 ms | 384 KB |
1_016.txt | AC | 9 ms | 384 KB |
1_017.txt | AC | 9 ms | 384 KB |
1_018.txt | AC | 9 ms | 384 KB |
1_019.txt | AC | 9 ms | 384 KB |
1_020.txt | AC | 9 ms | 384 KB |
1_021.txt | AC | 9 ms | 384 KB |
1_022.txt | AC | 9 ms | 384 KB |
1_023.txt | AC | 9 ms | 384 KB |
1_024.txt | AC | 9 ms | 384 KB |
1_025.txt | AC | 9 ms | 384 KB |
1_026.txt | AC | 9 ms | 384 KB |
1_027.txt | AC | 9 ms | 384 KB |