답안 #843061

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
843061 2023-09-03T15:37:41 Z yahyobekabdunazarov Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
0 / 100
3000 ms 8520 KB
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define ff first
#define ss second
//... max1 .... max2
//... max2 .... max1
using namespace std;


void solve(){  
    int n, m;
    cin >> n >> m;
    int a[n];
    for(int &i: a) cin >> i;
    while(m--){
        int l, r, k, mx = 0, sum = 0, ok = 1;
        cin >> l >> r >> k;
        l--, r--;
        for(int i = l; i < r - 1; i++){
            if(a[i] > a[i + 1]) ok = 0;
        }
        if(ok){
            cout << "1\n";
            continue;
        }
        if(n <= 5000 && m <= 5000){
            for(int i = l; i <= r; i++){
                sum = max(sum, (a[i] + mx) * (a[i] < mx));
                mx = max(mx, a[i]);
            }
            cout << (sum <= k ? "1\n" : "0\n");
        }
        else{
            cout << "0\n";
        }
    }
}

int32_t main(){
 
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
 
    int t = 1;  
    //cin >> t;
    while(t--){
        solve();
        cout << '\n';
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 344 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 344 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3038 ms 8520 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1617 ms 1396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 344 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 344 KB Output isn't correct
4 Halted 0 ms 0 KB -