Submission
Status:
PPPPPPPPPPP
Score: 100
User: Dormon
Problemset: ซอมบี้
Language: cpp
Time: 0.112 second
Submitted On: 2024-11-17 12:51:38
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#define debug(...) Debug(#__VA_ARGS__, __VA_ARGS__)
using namespace std;
template<typename T>
typename std::enable_if<std::is_integral<T>::value>::type
Debug(const char* name, T value) {
std::cout << name << " : " << value << '\n';
}
template<typename T, typename... Args>
typename std::enable_if<std::is_integral<T>::value>::type
Debug(const char* names, T value, Args... args) {
const char* comma = strchr(names, ',');
std::cout.write(names, comma - names) << " : " << value << " | ";
Debug(comma + 1, args...);
}
void solve(){
int n, k; cin >> n >> k;
vector<int> a(n, 0);
for (int i = 0;i < n;i++)
cin >> a[i];
for (int i = 0, v;i < n;i++){
cin >> v;
a[i] += v;
}
int l = 0, bullet = 0;
for (int i = 0;i < n;i++){
bullet += k;
while (bullet >= a[l] && l < n){
bullet -= a[l];
a[l] = 0;
l++;
}
if (a[i] > 0){
cout << "GG\n";
return ;
}
}
cout << "YAY\n";
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int q = 1;
//cin >> q;
while (q--){
solve();
}
}