답안 #973402

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
973402 2024-05-01T23:04:08 Z colossal_pepe Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
17 / 100
3000 ms 8272 KB
#include <bits/stdc++.h>
using namespace std;

int n, m;
vector<int> a;

int cost(int l, int r) {
    vector<int> c(n, 0);
    stack<int> st;
    for (int i = 0; i <= r; i++) {
        while (not st.empty() and a[st.top()] <= a[i]) st.pop();
        if (not st.empty()) c[st.top()] = a[st.top()] + a[i];
        st.push(i);
    }
    int ret = 0;
    for (int i = l; i <= r; i++) {
        ret = max(ret, c[i]);
    }
    return ret;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (n > 5000) exit(0);
    cin >> n >> m;
    a.resize(n);
    for (int &x : a) {
        cin >> x;
    }
    while (m--) {
        int l, r, k;
        cin >> l >> r >> k;
        l--, r--;
        cout << (cost(l, r) <= k) << '\n';
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 17 ms 348 KB Output is correct
12 Correct 61 ms 472 KB Output is correct
13 Correct 72 ms 344 KB Output is correct
14 Correct 125 ms 348 KB Output is correct
15 Correct 123 ms 476 KB Output is correct
16 Correct 86 ms 344 KB Output is correct
17 Correct 53 ms 484 KB Output is correct
18 Correct 86 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3089 ms 8272 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3041 ms 1240 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 17 ms 348 KB Output is correct
12 Correct 61 ms 472 KB Output is correct
13 Correct 72 ms 344 KB Output is correct
14 Correct 125 ms 348 KB Output is correct
15 Correct 123 ms 476 KB Output is correct
16 Correct 86 ms 344 KB Output is correct
17 Correct 53 ms 484 KB Output is correct
18 Correct 86 ms 344 KB Output is correct
19 Execution timed out 3070 ms 2024 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 17 ms 348 KB Output is correct
12 Correct 61 ms 472 KB Output is correct
13 Correct 72 ms 344 KB Output is correct
14 Correct 125 ms 348 KB Output is correct
15 Correct 123 ms 476 KB Output is correct
16 Correct 86 ms 344 KB Output is correct
17 Correct 53 ms 484 KB Output is correct
18 Correct 86 ms 344 KB Output is correct
19 Execution timed out 3089 ms 8272 KB Time limit exceeded
20 Halted 0 ms 0 KB -