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.078 second
Submitted On: 2026-11-10 10:50:11
#include <bits/stdc++.h>
using namespace std;
#define en '\n'
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
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){
cout << i;
return 0;
}
}
cout << -1;
}