Submission
Status:
PPPPTPTPTPT
Score: 70
User: generality
Problemset: ซอมบี้
Language: cpp
Time: 1.096 second
Submitted On: 2024-12-08 15:43:43
#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 now = day;
int currAmmo = ammo;
while(currAmmo>0 and now<n){
if(a1[now]>0 or a2[now]>0){
if(a1[now]>=a2[now]){
while(a1[now]>0 and currAmmo>0){
a1[now]--;
currAmmo--;
}
while(a2[now]>0 and currAmmo>0){
a2[now]--;
currAmmo--;
}
}
else{
while(a2[now]>0 and currAmmo>0){
a2[now]--;
currAmmo--;
}
while(a1[now]>0 and currAmmo>0){
a1[now]--;
currAmmo--;
}
}
}
now++;
}
if(a1[day]>0 or a2[day]>0){
cout<<"GG";
return 0;
}
day++;
}
cout<<"YAY"<<endl;
}