답안 #992764

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
992764 2024-06-05T06:59:59 Z danikoynov Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
17 / 100
3000 ms 13508 KB
#include<bits/stdc++.h>
#define endl '\n'

using namespace std;
typedef long long ll;

void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const int maxn = 1e6 + 10;

int n, m, w[maxn];
void solve()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i ++)
    {
        cin >> w[i];
    }

    stack < int > st;
    vector < pair < int, int > > fun;


    for (int i = 1; i <= n; i ++)
    {
        while(!st.empty() && w[st.top()] <= w[i])
            st.pop();

        if (!st.empty())
        {
            fun.push_back({st.top(), i});
        }
        st.push(i);

    }

    for (int i = 1; i <= m; i ++)
    {
        int l, r, k;
        cin >> l >> r >> k;
        int mx = 0;

        for (pair < int, int > cur : fun)
        {
            if (cur.first >= l && cur.second <= r)
                mx = max(mx, w[cur.first] + w[cur.second]);
        }

        cout << (mx <= k) << endl;
    }
}

int main()
{
    speed();
    solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 420 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 420 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 5 ms 348 KB Output is correct
12 Correct 13 ms 596 KB Output is correct
13 Correct 15 ms 600 KB Output is correct
14 Correct 24 ms 604 KB Output is correct
15 Correct 24 ms 604 KB Output is correct
16 Correct 11 ms 604 KB Output is correct
17 Correct 6 ms 604 KB Output is correct
18 Correct 16 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3091 ms 13508 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3014 ms 3800 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 420 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 5 ms 348 KB Output is correct
12 Correct 13 ms 596 KB Output is correct
13 Correct 15 ms 600 KB Output is correct
14 Correct 24 ms 604 KB Output is correct
15 Correct 24 ms 604 KB Output is correct
16 Correct 11 ms 604 KB Output is correct
17 Correct 6 ms 604 KB Output is correct
18 Correct 16 ms 604 KB Output is correct
19 Execution timed out 3052 ms 6872 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 420 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 5 ms 348 KB Output is correct
12 Correct 13 ms 596 KB Output is correct
13 Correct 15 ms 600 KB Output is correct
14 Correct 24 ms 604 KB Output is correct
15 Correct 24 ms 604 KB Output is correct
16 Correct 11 ms 604 KB Output is correct
17 Correct 6 ms 604 KB Output is correct
18 Correct 16 ms 604 KB Output is correct
19 Execution timed out 3091 ms 13508 KB Time limit exceeded
20 Halted 0 ms 0 KB -