답안 #689507

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
689507 2023-01-28T16:47:47 Z nasir_bashirov Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++11
0 / 100
3000 ms 101596 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n, q, l, r, x;
    cin >> n >> q;
    pair<int, int> a[n + 1];
    int aa[n + 1];
    map<int, int>mp;
    mp[-1] = 0;
    aa[0] = -1;
    for(int i = 1; i <= n; i++){
        cin >> a[i].first;
        a[i].second = i;
        aa[i] = a[i].first;
    }
    sort(a + 1, a + n + 1);
    for(int i = 1; i <= n; i++){
        mp[a[i].second] = i;
    }
    while(q--){
        cin >> l >> r >> x;
        int mx = -1, last = -1, mn = INT_MAX;
        for(int i = l; i <= r; i++){
            if(mp[last] > mp[aa[i]]){
                mx = max({mx, aa[i], a[mp[last]].first});
            }
            last = max({last, mp[aa[i]]});
            mn = min(mn, mp[aa[i]]);

        }
        cout << (mn + mx <= x ? 1 : 0) << endl;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 284 KB Output is correct
3 Incorrect 3 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 284 KB Output is correct
3 Incorrect 3 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3082 ms 101596 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3097 ms 6064 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 284 KB Output is correct
3 Incorrect 3 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 284 KB Output is correct
3 Incorrect 3 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -