답안 #831601

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
831601 2023-08-20T11:13:00 Z Cookie Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
100 / 100
1209 ms 97588 KB
#include<bits/stdc++.h>
#include<fstream>
#pragma GCC optimize("Ofast,O3,unroll-loops")
#pragma GCC target("avx2")
using namespace std;
//ifstream fin("FEEDING.INP");
//ofstream fout("FEEDING.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const int base = 74;
const int mxn = 1e6 + 5;
const ll inf = 1e9;
int n, m;
int st[4 * mxn + 1], lz[4 * mxn + 1], a[mxn + 1], to[mxn + 1];
struct Q{
    int l, k, id;
};
vt<Q>queries[mxn + 1];
bool ans[mxn + 1];
vt<int>comp;
void upd(int nd, int l, int r, int id, int v){
    if(id < l || id > r)return;
    if(l == r){
        st[nd] = v;return;
    }
    int mid = (l + r) >> 1;
    upd(nd << 1, l, mid, id, v); upd(nd << 1 | 1, mid + 1, r, id, v);
    st[nd] = max(st[nd << 1], st[nd << 1 | 1]);
}
int get(int nd, int l, int r, int ql, int qr){
    if(ql > r || qr < l)return(0);
    if(ql <= l && qr >= r)return(st[nd]);
    int mid = (l + r) >> 1;
    return(max(get(nd << 1, l, mid, ql, qr), get(nd << 1 | 1, mid + 1, r, ql, qr)));
}
signed main()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    forr(i, 1, n + 1)cin >> a[i];
    deque<int>dq;
    for(int i = 1; i <= n; i++){
        while(sz(dq) && a[dq.back()] <= a[i])dq.pop_back();
        if(dq.size()){
            to[i] = dq.back();
        }else{
            to[i] = -1;
        }
        dq.pb(i);
    }
    for(int i = 0; i  < m; i++){
        int l, r, k; cin >> l >> r >> k;
        queries[r].pb({l, k, i});
    }
    for(int i = 1; i <= n; i++){
        if(to[i] != -1){
            upd(1, 1, n, to[i], a[i] + a[to[i]]);
        }
        for(auto [l, k, id]: queries[i]){
            int val = get(1, 1, n, l, i);
            ans[id] = (val <= k);
        }
    }
    for(int i = 0; i < m; i++)cout << ans[i] << "\n";
    return(0);
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:69:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   69 |         for(auto [l, k, id]: queries[i]){
      |                  ^
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 12 ms 23728 KB Output is correct
3 Correct 11 ms 23856 KB Output is correct
4 Correct 14 ms 23804 KB Output is correct
5 Correct 12 ms 23764 KB Output is correct
6 Correct 12 ms 23828 KB Output is correct
7 Correct 12 ms 23788 KB Output is correct
8 Correct 13 ms 23816 KB Output is correct
9 Correct 12 ms 23820 KB Output is correct
10 Correct 11 ms 23764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 12 ms 23728 KB Output is correct
3 Correct 11 ms 23856 KB Output is correct
4 Correct 14 ms 23804 KB Output is correct
5 Correct 12 ms 23764 KB Output is correct
6 Correct 12 ms 23828 KB Output is correct
7 Correct 12 ms 23788 KB Output is correct
8 Correct 13 ms 23816 KB Output is correct
9 Correct 12 ms 23820 KB Output is correct
10 Correct 11 ms 23764 KB Output is correct
11 Correct 13 ms 23892 KB Output is correct
12 Correct 13 ms 24064 KB Output is correct
13 Correct 15 ms 24020 KB Output is correct
14 Correct 15 ms 24160 KB Output is correct
15 Correct 19 ms 24076 KB Output is correct
16 Correct 14 ms 24012 KB Output is correct
17 Correct 14 ms 24004 KB Output is correct
18 Correct 14 ms 24092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1063 ms 96500 KB Output is correct
2 Correct 1020 ms 97368 KB Output is correct
3 Correct 1071 ms 97336 KB Output is correct
4 Correct 1078 ms 97584 KB Output is correct
5 Correct 889 ms 89248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 29952 KB Output is correct
2 Correct 76 ms 29676 KB Output is correct
3 Correct 68 ms 28844 KB Output is correct
4 Correct 79 ms 28900 KB Output is correct
5 Correct 75 ms 28936 KB Output is correct
6 Correct 65 ms 28408 KB Output is correct
7 Correct 58 ms 28464 KB Output is correct
8 Correct 69 ms 28484 KB Output is correct
9 Correct 38 ms 26820 KB Output is correct
10 Correct 71 ms 28472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 12 ms 23728 KB Output is correct
3 Correct 11 ms 23856 KB Output is correct
4 Correct 14 ms 23804 KB Output is correct
5 Correct 12 ms 23764 KB Output is correct
6 Correct 12 ms 23828 KB Output is correct
7 Correct 12 ms 23788 KB Output is correct
8 Correct 13 ms 23816 KB Output is correct
9 Correct 12 ms 23820 KB Output is correct
10 Correct 11 ms 23764 KB Output is correct
11 Correct 13 ms 23892 KB Output is correct
12 Correct 13 ms 24064 KB Output is correct
13 Correct 15 ms 24020 KB Output is correct
14 Correct 15 ms 24160 KB Output is correct
15 Correct 19 ms 24076 KB Output is correct
16 Correct 14 ms 24012 KB Output is correct
17 Correct 14 ms 24004 KB Output is correct
18 Correct 14 ms 24092 KB Output is correct
19 Correct 191 ms 38860 KB Output is correct
20 Correct 184 ms 38796 KB Output is correct
21 Correct 145 ms 38220 KB Output is correct
22 Correct 156 ms 38084 KB Output is correct
23 Correct 155 ms 38104 KB Output is correct
24 Correct 130 ms 35984 KB Output is correct
25 Correct 114 ms 35996 KB Output is correct
26 Correct 157 ms 36300 KB Output is correct
27 Correct 134 ms 36312 KB Output is correct
28 Correct 139 ms 36388 KB Output is correct
29 Correct 179 ms 36752 KB Output is correct
30 Correct 147 ms 36712 KB Output is correct
31 Correct 163 ms 36684 KB Output is correct
32 Correct 164 ms 36800 KB Output is correct
33 Correct 146 ms 36684 KB Output is correct
34 Correct 135 ms 35528 KB Output is correct
35 Correct 106 ms 35488 KB Output is correct
36 Correct 105 ms 35420 KB Output is correct
37 Correct 108 ms 35300 KB Output is correct
38 Correct 110 ms 35504 KB Output is correct
39 Correct 163 ms 35716 KB Output is correct
40 Correct 107 ms 33496 KB Output is correct
41 Correct 159 ms 34724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 12 ms 23728 KB Output is correct
3 Correct 11 ms 23856 KB Output is correct
4 Correct 14 ms 23804 KB Output is correct
5 Correct 12 ms 23764 KB Output is correct
6 Correct 12 ms 23828 KB Output is correct
7 Correct 12 ms 23788 KB Output is correct
8 Correct 13 ms 23816 KB Output is correct
9 Correct 12 ms 23820 KB Output is correct
10 Correct 11 ms 23764 KB Output is correct
11 Correct 13 ms 23892 KB Output is correct
12 Correct 13 ms 24064 KB Output is correct
13 Correct 15 ms 24020 KB Output is correct
14 Correct 15 ms 24160 KB Output is correct
15 Correct 19 ms 24076 KB Output is correct
16 Correct 14 ms 24012 KB Output is correct
17 Correct 14 ms 24004 KB Output is correct
18 Correct 14 ms 24092 KB Output is correct
19 Correct 1063 ms 96500 KB Output is correct
20 Correct 1020 ms 97368 KB Output is correct
21 Correct 1071 ms 97336 KB Output is correct
22 Correct 1078 ms 97584 KB Output is correct
23 Correct 889 ms 89248 KB Output is correct
24 Correct 79 ms 29952 KB Output is correct
25 Correct 76 ms 29676 KB Output is correct
26 Correct 68 ms 28844 KB Output is correct
27 Correct 79 ms 28900 KB Output is correct
28 Correct 75 ms 28936 KB Output is correct
29 Correct 65 ms 28408 KB Output is correct
30 Correct 58 ms 28464 KB Output is correct
31 Correct 69 ms 28484 KB Output is correct
32 Correct 38 ms 26820 KB Output is correct
33 Correct 71 ms 28472 KB Output is correct
34 Correct 191 ms 38860 KB Output is correct
35 Correct 184 ms 38796 KB Output is correct
36 Correct 145 ms 38220 KB Output is correct
37 Correct 156 ms 38084 KB Output is correct
38 Correct 155 ms 38104 KB Output is correct
39 Correct 130 ms 35984 KB Output is correct
40 Correct 114 ms 35996 KB Output is correct
41 Correct 157 ms 36300 KB Output is correct
42 Correct 134 ms 36312 KB Output is correct
43 Correct 139 ms 36388 KB Output is correct
44 Correct 179 ms 36752 KB Output is correct
45 Correct 147 ms 36712 KB Output is correct
46 Correct 163 ms 36684 KB Output is correct
47 Correct 164 ms 36800 KB Output is correct
48 Correct 146 ms 36684 KB Output is correct
49 Correct 135 ms 35528 KB Output is correct
50 Correct 106 ms 35488 KB Output is correct
51 Correct 105 ms 35420 KB Output is correct
52 Correct 108 ms 35300 KB Output is correct
53 Correct 110 ms 35504 KB Output is correct
54 Correct 163 ms 35716 KB Output is correct
55 Correct 107 ms 33496 KB Output is correct
56 Correct 159 ms 34724 KB Output is correct
57 Correct 1209 ms 97588 KB Output is correct
58 Correct 1109 ms 97576 KB Output is correct
59 Correct 1014 ms 96008 KB Output is correct
60 Correct 919 ms 96192 KB Output is correct
61 Correct 1034 ms 96068 KB Output is correct
62 Correct 1000 ms 96048 KB Output is correct
63 Correct 581 ms 84592 KB Output is correct
64 Correct 555 ms 84540 KB Output is correct
65 Correct 906 ms 87652 KB Output is correct
66 Correct 907 ms 87700 KB Output is correct
67 Correct 811 ms 87728 KB Output is correct
68 Correct 892 ms 89408 KB Output is correct
69 Correct 935 ms 89396 KB Output is correct
70 Correct 879 ms 89056 KB Output is correct
71 Correct 903 ms 89256 KB Output is correct
72 Correct 889 ms 89144 KB Output is correct
73 Correct 546 ms 80584 KB Output is correct
74 Correct 551 ms 81464 KB Output is correct
75 Correct 513 ms 80596 KB Output is correct
76 Correct 529 ms 80624 KB Output is correct
77 Correct 528 ms 80408 KB Output is correct
78 Correct 856 ms 84220 KB Output is correct
79 Correct 623 ms 70704 KB Output is correct
80 Correct 800 ms 78652 KB Output is correct