Submission
Status:
(PPPPPPPPPPPPP)(PPPTSSS)(SSSSSSSSS)
Subtask/Task Score:
{30/30}{0/30}{0/40}
Score: 30
User: UNJE0o
Problemset: Red Zone
Language: cpp
Time: 1.072 second
Submitted On: 2026-11-10 10:48:29
#include <bits/stdc++.h>
using namespace std;
#define en '\n'
int main(){
int n,m,r,d;
// n = home, m = boom , r = radian , d = damage
cin >> n >> m >> r >> d;
int h[n],pos;
for(int i = 0;i < n;i++) cin >> h[i];
set<int>c;
for(int i = 1;i <= m;i++){
cin >> pos;
pos -= 1;
for(int j = 0;j <= r && pos + j < n;j++){
h[pos+j] -= d;
if (h[pos+j] <= 0) c.insert(pos + j);
}
for(int j = 1;j <= r && pos - j >= 0;j++){
h[pos - j] -= d;
if (h[pos-j] <= 0) c.insert(pos - j);
}
if(c.size() == n){
// for(int j = 0;j < n;j++) cout << h[j] << " ";
// cout << c.size() << " " << en;
cout << i;
return 0;
}
}
cout << -1;
}