Submission

Status:

Compilation Error

Subtask/Task Score:

Score: 0

User: devilpoohs

Problemset: Red Zone

Language: cpp

Time: 0.000 second

Submitted On: 2026-03-07 07:59:20

#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;
    for(int i=1;i<=m;i++){
        cin>>a;
        int s=max(a-l,0),e=min(a+l,n-1);
        // 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

*/