Submission
Status:
PPPPTPTPTPT
Score: 70
User: generality
Problemset: ซอมบี้
Language: cpp
Time: 1.095 second
Submitted On: 2024-12-08 15:46:33
#include <bits/stdc++.h>
using namespace std;
int n, ammo;
const int N = 1e6 + 10;
vector<int> a1(N);
vector<int> a2(N);
int main() {
ios::sync_with_stdio(false); cin.tie(0);
cin >> n >> ammo;
for (int i = 0; i < n; i++) cin >> a1[i];
for (int i = 0; i < n; i++) cin >> a2[i];
int day = 0;
while (day < n) {
int currAmmo = ammo;
int now = day;
while (currAmmo > 0 && now < n) {
int useAmmoA1 = min(currAmmo, a1[now]);
a1[now] -= useAmmoA1;
currAmmo -= useAmmoA1;
int useAmmoA2 = min(currAmmo, a2[now]);
a2[now] -= useAmmoA2;
currAmmo -= useAmmoA2;
now++;
}
if (a1[day] > 0 || a2[day] > 0) {
cout << "GG";
return 0;
}
day++;
}
cout << "YAY" << endl;
return 0;
}