Submission #508267

# Submission time Handle Problem Language Result Execution time Memory
508267 2022-01-13T08:03:26 Z Belgutei Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
0 / 100
1 ms 460 KB
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll n,m;
ll a[5005];
ll l,r,k;

int main(){
    IOS
    cin>>n>>m;
    for(int i=1; i<=n; i++){
        cin>>a[i];
    }
    while(m--){
        cin>>l>>r>>k;
        ll mx=a[l];
        ll mn=a[l];
        bool ok=1;
        for(int i=l+1; i<=r; i++){
            if(mx>a[i]){
                if(mx-a[i]>k){
                    ok=0;
                    break;
                }
            }
            if(mn>a[i]){
                if(mn-a[i]>k){
                    ok=0;
                    break;
                }
            }
            mx=max(mx,a[i]);
            mn=min(mn,a[i]);
        }
        cout<<ok<<'\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -