답안 #689505

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
689505 2023-01-28T16:44:12 Z nasir_bashirov Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++11
0 / 100
3000 ms 111688 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, aa[i]);

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