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