제출 #1311796

#제출 시각아이디문제언어결과실행 시간메모리
1311796hasanHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++20
0 / 100
3095 ms31232 KiB
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define int int_fast32_t
#define ul uint_fast32_t
#define ll int_fast64_t
#define dll long double
#define ull uint_fast64_t
#define spektar this_thread::sleep_for(chrono::milliseconds(50))

void solve(){
    int n,m;
    cin >> n >> m;
    vector<int> k(n);
    for(auto& i:k) cin >> i;
    vector<int> k1=k;
    sort(k1.begin(),k1.end());
    for(int i=0; i<m; i++){
        int a,b,c;
        cin >> a >> b >> c;
        bool ka=true;
        int max1=0;
        vector<int> kk;
        for(int j=a-1; j<=b-1; j++) kk.push_back(k[j]);
        sort(kk.begin(),kk.end());
        for(int j=a-1; j<=b-1; j++){
            if(kk[j-(a-1)]!=k[j]){
                max1=max(max1,k[j]);
                ka=false;
            }
        }
        if(ka) cout << 1 << endl;
        else if(max1+kk[0]>c) cout << 0 << endl;
        else cout << 1 << endl;
    }
}

signed main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t=1;
    //cin >> t;
    while(t--){
        solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...