# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
173205 | 2020-01-03T14:59:57 Z | srvlt | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++14 | 1068 ms | 61616 KB |
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; const int N = 1e6 + 7; int n, m, a[N], last[N], bad[N]; struct query { int l, r, k, ind; bool operator < (const query & q) const { return r < q.r; } } v[N]; set <pair <int, int> > cont; inline void update(int x, int y) { auto p = cont.insert({x, y}).first; if (p != (--cont.end()) && (*next(p)).second > y) { cont.erase(p); return; } while (p != cont.begin() && (*prev(p)).second < y) cont.erase(prev(p)); } inline int query(int x) { if (cont.empty()) return 0; auto p = cont.lower_bound({x, 0}); if (p == cont.end()) return 0; return (*p).second; } int main() { scanf("%d %d", & n, & m); stack <int> s; for (int i = 1; i <= n; i++) { scanf("%d", & a[i]); while (!s.empty() && a[s.top()] <= a[i]) s.pop(); if (!s.empty()) last[i] = s.top(); s.push(i); } for (int i = 0; i < m; i++) scanf("%d %d %d", & v[i].l, & v[i].r, & v[i].k), v[i].ind = i; sort(v, v + m); int j = 1; for (int i = 0; i < m; i++) { while (j <= v[i].r) { if (j) update(last[j], a[j] + a[last[j]]); j++; } bad[v[i].ind] = (query(v[i].l) > v[i].k); } for (int i = 0; i < m; i++) cout << (bad[i] ? "0" : "1") << "\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 4 ms | 504 KB | Output is correct |
12 | Correct | 5 ms | 504 KB | Output is correct |
13 | Correct | 5 ms | 632 KB | Output is correct |
14 | Correct | 7 ms | 636 KB | Output is correct |
15 | Correct | 7 ms | 632 KB | Output is correct |
16 | Correct | 6 ms | 636 KB | Output is correct |
17 | Correct | 5 ms | 632 KB | Output is correct |
18 | Correct | 5 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1006 ms | 61616 KB | Output is correct |
2 | Correct | 999 ms | 58580 KB | Output is correct |
3 | Correct | 994 ms | 58260 KB | Output is correct |
4 | Correct | 994 ms | 58488 KB | Output is correct |
5 | Correct | 891 ms | 54464 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 84 ms | 5240 KB | Output is correct |
2 | Correct | 81 ms | 5212 KB | Output is correct |
3 | Correct | 67 ms | 4856 KB | Output is correct |
4 | Correct | 67 ms | 4816 KB | Output is correct |
5 | Correct | 68 ms | 4856 KB | Output is correct |
6 | Correct | 61 ms | 4728 KB | Output is correct |
7 | Correct | 61 ms | 4704 KB | Output is correct |
8 | Correct | 64 ms | 4936 KB | Output is correct |
9 | Correct | 47 ms | 3832 KB | Output is correct |
10 | Correct | 62 ms | 4732 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 4 ms | 504 KB | Output is correct |
12 | Correct | 5 ms | 504 KB | Output is correct |
13 | Correct | 5 ms | 632 KB | Output is correct |
14 | Correct | 7 ms | 636 KB | Output is correct |
15 | Correct | 7 ms | 632 KB | Output is correct |
16 | Correct | 6 ms | 636 KB | Output is correct |
17 | Correct | 5 ms | 632 KB | Output is correct |
18 | Correct | 5 ms | 504 KB | Output is correct |
19 | Correct | 196 ms | 12876 KB | Output is correct |
20 | Correct | 195 ms | 12864 KB | Output is correct |
21 | Correct | 181 ms | 12664 KB | Output is correct |
22 | Correct | 181 ms | 12664 KB | Output is correct |
23 | Correct | 181 ms | 12668 KB | Output is correct |
24 | Correct | 163 ms | 11748 KB | Output is correct |
25 | Correct | 163 ms | 11768 KB | Output is correct |
26 | Correct | 167 ms | 11924 KB | Output is correct |
27 | Correct | 168 ms | 11896 KB | Output is correct |
28 | Correct | 168 ms | 12008 KB | Output is correct |
29 | Correct | 173 ms | 12052 KB | Output is correct |
30 | Correct | 174 ms | 12024 KB | Output is correct |
31 | Correct | 172 ms | 12024 KB | Output is correct |
32 | Correct | 174 ms | 12056 KB | Output is correct |
33 | Correct | 172 ms | 12024 KB | Output is correct |
34 | Correct | 151 ms | 11808 KB | Output is correct |
35 | Correct | 149 ms | 11772 KB | Output is correct |
36 | Correct | 148 ms | 11508 KB | Output is correct |
37 | Correct | 148 ms | 11512 KB | Output is correct |
38 | Correct | 149 ms | 11640 KB | Output is correct |
39 | Correct | 164 ms | 10988 KB | Output is correct |
40 | Correct | 133 ms | 9820 KB | Output is correct |
41 | Correct | 136 ms | 10588 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 4 ms | 504 KB | Output is correct |
12 | Correct | 5 ms | 504 KB | Output is correct |
13 | Correct | 5 ms | 632 KB | Output is correct |
14 | Correct | 7 ms | 636 KB | Output is correct |
15 | Correct | 7 ms | 632 KB | Output is correct |
16 | Correct | 6 ms | 636 KB | Output is correct |
17 | Correct | 5 ms | 632 KB | Output is correct |
18 | Correct | 5 ms | 504 KB | Output is correct |
19 | Correct | 1006 ms | 61616 KB | Output is correct |
20 | Correct | 999 ms | 58580 KB | Output is correct |
21 | Correct | 994 ms | 58260 KB | Output is correct |
22 | Correct | 994 ms | 58488 KB | Output is correct |
23 | Correct | 891 ms | 54464 KB | Output is correct |
24 | Correct | 84 ms | 5240 KB | Output is correct |
25 | Correct | 81 ms | 5212 KB | Output is correct |
26 | Correct | 67 ms | 4856 KB | Output is correct |
27 | Correct | 67 ms | 4816 KB | Output is correct |
28 | Correct | 68 ms | 4856 KB | Output is correct |
29 | Correct | 61 ms | 4728 KB | Output is correct |
30 | Correct | 61 ms | 4704 KB | Output is correct |
31 | Correct | 64 ms | 4936 KB | Output is correct |
32 | Correct | 47 ms | 3832 KB | Output is correct |
33 | Correct | 62 ms | 4732 KB | Output is correct |
34 | Correct | 196 ms | 12876 KB | Output is correct |
35 | Correct | 195 ms | 12864 KB | Output is correct |
36 | Correct | 181 ms | 12664 KB | Output is correct |
37 | Correct | 181 ms | 12664 KB | Output is correct |
38 | Correct | 181 ms | 12668 KB | Output is correct |
39 | Correct | 163 ms | 11748 KB | Output is correct |
40 | Correct | 163 ms | 11768 KB | Output is correct |
41 | Correct | 167 ms | 11924 KB | Output is correct |
42 | Correct | 168 ms | 11896 KB | Output is correct |
43 | Correct | 168 ms | 12008 KB | Output is correct |
44 | Correct | 173 ms | 12052 KB | Output is correct |
45 | Correct | 174 ms | 12024 KB | Output is correct |
46 | Correct | 172 ms | 12024 KB | Output is correct |
47 | Correct | 174 ms | 12056 KB | Output is correct |
48 | Correct | 172 ms | 12024 KB | Output is correct |
49 | Correct | 151 ms | 11808 KB | Output is correct |
50 | Correct | 149 ms | 11772 KB | Output is correct |
51 | Correct | 148 ms | 11508 KB | Output is correct |
52 | Correct | 148 ms | 11512 KB | Output is correct |
53 | Correct | 149 ms | 11640 KB | Output is correct |
54 | Correct | 164 ms | 10988 KB | Output is correct |
55 | Correct | 133 ms | 9820 KB | Output is correct |
56 | Correct | 136 ms | 10588 KB | Output is correct |
57 | Correct | 997 ms | 49956 KB | Output is correct |
58 | Correct | 1068 ms | 58720 KB | Output is correct |
59 | Correct | 960 ms | 31608 KB | Output is correct |
60 | Correct | 973 ms | 42440 KB | Output is correct |
61 | Correct | 981 ms | 56568 KB | Output is correct |
62 | Correct | 987 ms | 58148 KB | Output is correct |
63 | Correct | 809 ms | 55696 KB | Output is correct |
64 | Correct | 806 ms | 31352 KB | Output is correct |
65 | Correct | 897 ms | 48208 KB | Output is correct |
66 | Correct | 884 ms | 59340 KB | Output is correct |
67 | Correct | 887 ms | 59168 KB | Output is correct |
68 | Correct | 910 ms | 59384 KB | Output is correct |
69 | Correct | 893 ms | 50484 KB | Output is correct |
70 | Correct | 908 ms | 55772 KB | Output is correct |
71 | Correct | 903 ms | 58704 KB | Output is correct |
72 | Correct | 893 ms | 58852 KB | Output is correct |
73 | Correct | 737 ms | 55964 KB | Output is correct |
74 | Correct | 747 ms | 54072 KB | Output is correct |
75 | Correct | 739 ms | 55428 KB | Output is correct |
76 | Correct | 744 ms | 55380 KB | Output is correct |
77 | Correct | 740 ms | 53176 KB | Output is correct |
78 | Correct | 840 ms | 54028 KB | Output is correct |
79 | Correct | 648 ms | 46884 KB | Output is correct |
80 | Correct | 706 ms | 53252 KB | Output is correct |