Submission
Status:
(PPPPPPPPPPPPP)(PPPTSSS)(SSSSSSSSS)
Subtask/Task Score:
{30/30}{0/30}{0/40}
Score: 30
User: devilpoohs
Problemset: Red Zone
Language: cpp
Time: 1.093 second
Submitted On: 2026-03-07 08:28:28
#include<bits/stdc++.h>
using namespace std;
int n,d;
bool chk(int ar[],int pl[]){
int pls=0;
for(int i=0;i<n;i++){
pls+=pl[i];
if(ar[i]-pls*d>0) return false;
}
return true;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int m,l;
cin>>n>>m>>l>>d;
int ar[n];
int pl[n+1];
memset(pl,0,sizeof(pl));
for(int i=0;i<n;i++){
cin>>ar[i];
}
int a;
bool chk2=false;
for(int i=1;i<=m;i++){
cin>>a;
a--;
int s=max(a-l,0),e=min(a+l,n-1);
// cout<<s<<'.'<<e;
// cout<<'\n';
pl[s]++;
pl[e+1]--;
// for(int j=s;j<=e;j++){
// ar[j]-=d;
// }
if(chk(ar,pl) and chk2==false){
cout<<i;
return 0;
}
}
cout<<-1;
return 0;
}
/*
6 8 1 4
4 7 6 2 5 3
1
3
6
1
4
6
5
3
*/