답안 #333016

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
333016 2020-12-04T09:01:33 Z Boaba Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
100 / 100
1231 ms 109104 KB
#include <cstdio>
#include <vector>
#define Max(a, b) (((a) < (b)) ? (b) : (a))
#pragma GCC optimize ("O3")

const int nmax = 1e6 + 5;

struct day {
    int st, dr, ind, k;
};

int v[nmax], aib[nmax], n, m;
bool ans[nmax];
std::vector<int>st, last[nmax];
std::vector<day>skema[nmax];

void update(int poz, int val) {
    for (; poz <= n; poz += poz & (-poz))
        aib[poz] = Max(aib[poz], val);
}

int query(int poz) {
    int ans = 0;
    for (; poz > 0; poz -= poz & (-poz))
        ans = Max(ans, aib[poz]);
    return ans;
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++){
        scanf("%d", &v[i]);
        while (!st.empty() and v[st.back()] <= v[i]) st.pop_back();
        if (!st.empty()) last[st.back()].push_back(i);
        st.push_back(i);
    }
    for (int i = 1; i <= m; i++) {
        day aux;
        scanf("%d %d %d", &aux.st, &aux.dr, &aux.k);
        aux.ind = i;
        skema[aux.st].push_back(aux);
    }
    for (int i = n; i > 0; i--) {
        for (int x : last[i]) update(x, v[x] + v[i]);
        for (day aux : skema[i]) ans[aux.ind] = (query(aux.dr) <= aux.k);
    }
    for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
    return 0;
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   30 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
sortbooks.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   32 |         scanf("%d", &v[i]);
      |         ~~~~~^~~~~~~~~~~~~
sortbooks.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   39 |         scanf("%d %d %d", &aux.st, &aux.dr, &aux.k);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 47468 KB Output is correct
2 Correct 33 ms 47340 KB Output is correct
3 Correct 32 ms 47340 KB Output is correct
4 Correct 32 ms 47340 KB Output is correct
5 Correct 32 ms 47468 KB Output is correct
6 Correct 33 ms 47340 KB Output is correct
7 Correct 33 ms 47340 KB Output is correct
8 Correct 33 ms 47340 KB Output is correct
9 Correct 32 ms 47340 KB Output is correct
10 Correct 33 ms 47340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 47468 KB Output is correct
2 Correct 33 ms 47340 KB Output is correct
3 Correct 32 ms 47340 KB Output is correct
4 Correct 32 ms 47340 KB Output is correct
5 Correct 32 ms 47468 KB Output is correct
6 Correct 33 ms 47340 KB Output is correct
7 Correct 33 ms 47340 KB Output is correct
8 Correct 33 ms 47340 KB Output is correct
9 Correct 32 ms 47340 KB Output is correct
10 Correct 33 ms 47340 KB Output is correct
11 Correct 34 ms 47468 KB Output is correct
12 Correct 35 ms 47596 KB Output is correct
13 Correct 38 ms 47596 KB Output is correct
14 Correct 37 ms 47724 KB Output is correct
15 Correct 37 ms 47724 KB Output is correct
16 Correct 36 ms 47596 KB Output is correct
17 Correct 36 ms 47596 KB Output is correct
18 Correct 36 ms 47596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1182 ms 102508 KB Output is correct
2 Correct 1194 ms 107756 KB Output is correct
3 Correct 1231 ms 108140 KB Output is correct
4 Correct 1202 ms 108140 KB Output is correct
5 Correct 1049 ms 90860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 127 ms 54508 KB Output is correct
2 Correct 110 ms 54636 KB Output is correct
3 Correct 106 ms 52716 KB Output is correct
4 Correct 105 ms 52588 KB Output is correct
5 Correct 109 ms 52716 KB Output is correct
6 Correct 90 ms 52204 KB Output is correct
7 Correct 94 ms 52204 KB Output is correct
8 Correct 108 ms 52576 KB Output is correct
9 Correct 76 ms 50912 KB Output is correct
10 Correct 100 ms 52324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 47468 KB Output is correct
2 Correct 33 ms 47340 KB Output is correct
3 Correct 32 ms 47340 KB Output is correct
4 Correct 32 ms 47340 KB Output is correct
5 Correct 32 ms 47468 KB Output is correct
6 Correct 33 ms 47340 KB Output is correct
7 Correct 33 ms 47340 KB Output is correct
8 Correct 33 ms 47340 KB Output is correct
9 Correct 32 ms 47340 KB Output is correct
10 Correct 33 ms 47340 KB Output is correct
11 Correct 34 ms 47468 KB Output is correct
12 Correct 35 ms 47596 KB Output is correct
13 Correct 38 ms 47596 KB Output is correct
14 Correct 37 ms 47724 KB Output is correct
15 Correct 37 ms 47724 KB Output is correct
16 Correct 36 ms 47596 KB Output is correct
17 Correct 36 ms 47596 KB Output is correct
18 Correct 36 ms 47596 KB Output is correct
19 Correct 248 ms 59884 KB Output is correct
20 Correct 252 ms 64620 KB Output is correct
21 Correct 219 ms 64344 KB Output is correct
22 Correct 220 ms 64364 KB Output is correct
23 Correct 215 ms 64364 KB Output is correct
24 Correct 187 ms 60304 KB Output is correct
25 Correct 184 ms 60268 KB Output is correct
26 Correct 210 ms 60396 KB Output is correct
27 Correct 207 ms 60396 KB Output is correct
28 Correct 212 ms 60524 KB Output is correct
29 Correct 223 ms 60732 KB Output is correct
30 Correct 241 ms 60780 KB Output is correct
31 Correct 225 ms 60524 KB Output is correct
32 Correct 230 ms 60640 KB Output is correct
33 Correct 221 ms 60652 KB Output is correct
34 Correct 169 ms 59372 KB Output is correct
35 Correct 177 ms 59516 KB Output is correct
36 Correct 169 ms 59372 KB Output is correct
37 Correct 169 ms 59244 KB Output is correct
38 Correct 169 ms 59500 KB Output is correct
39 Correct 202 ms 60056 KB Output is correct
40 Correct 174 ms 57308 KB Output is correct
41 Correct 200 ms 58828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 47468 KB Output is correct
2 Correct 33 ms 47340 KB Output is correct
3 Correct 32 ms 47340 KB Output is correct
4 Correct 32 ms 47340 KB Output is correct
5 Correct 32 ms 47468 KB Output is correct
6 Correct 33 ms 47340 KB Output is correct
7 Correct 33 ms 47340 KB Output is correct
8 Correct 33 ms 47340 KB Output is correct
9 Correct 32 ms 47340 KB Output is correct
10 Correct 33 ms 47340 KB Output is correct
11 Correct 34 ms 47468 KB Output is correct
12 Correct 35 ms 47596 KB Output is correct
13 Correct 38 ms 47596 KB Output is correct
14 Correct 37 ms 47724 KB Output is correct
15 Correct 37 ms 47724 KB Output is correct
16 Correct 36 ms 47596 KB Output is correct
17 Correct 36 ms 47596 KB Output is correct
18 Correct 36 ms 47596 KB Output is correct
19 Correct 1182 ms 102508 KB Output is correct
20 Correct 1194 ms 107756 KB Output is correct
21 Correct 1231 ms 108140 KB Output is correct
22 Correct 1202 ms 108140 KB Output is correct
23 Correct 1049 ms 90860 KB Output is correct
24 Correct 127 ms 54508 KB Output is correct
25 Correct 110 ms 54636 KB Output is correct
26 Correct 106 ms 52716 KB Output is correct
27 Correct 105 ms 52588 KB Output is correct
28 Correct 109 ms 52716 KB Output is correct
29 Correct 90 ms 52204 KB Output is correct
30 Correct 94 ms 52204 KB Output is correct
31 Correct 108 ms 52576 KB Output is correct
32 Correct 76 ms 50912 KB Output is correct
33 Correct 100 ms 52324 KB Output is correct
34 Correct 248 ms 59884 KB Output is correct
35 Correct 252 ms 64620 KB Output is correct
36 Correct 219 ms 64344 KB Output is correct
37 Correct 220 ms 64364 KB Output is correct
38 Correct 215 ms 64364 KB Output is correct
39 Correct 187 ms 60304 KB Output is correct
40 Correct 184 ms 60268 KB Output is correct
41 Correct 210 ms 60396 KB Output is correct
42 Correct 207 ms 60396 KB Output is correct
43 Correct 212 ms 60524 KB Output is correct
44 Correct 223 ms 60732 KB Output is correct
45 Correct 241 ms 60780 KB Output is correct
46 Correct 225 ms 60524 KB Output is correct
47 Correct 230 ms 60640 KB Output is correct
48 Correct 221 ms 60652 KB Output is correct
49 Correct 169 ms 59372 KB Output is correct
50 Correct 177 ms 59516 KB Output is correct
51 Correct 169 ms 59372 KB Output is correct
52 Correct 169 ms 59244 KB Output is correct
53 Correct 169 ms 59500 KB Output is correct
54 Correct 202 ms 60056 KB Output is correct
55 Correct 174 ms 57308 KB Output is correct
56 Correct 200 ms 58828 KB Output is correct
57 Correct 1220 ms 108972 KB Output is correct
58 Correct 1223 ms 109104 KB Output is correct
59 Correct 1168 ms 108780 KB Output is correct
60 Correct 1179 ms 108744 KB Output is correct
61 Correct 1172 ms 108792 KB Output is correct
62 Correct 1190 ms 108632 KB Output is correct
63 Correct 782 ms 84228 KB Output is correct
64 Correct 782 ms 84392 KB Output is correct
65 Correct 1043 ms 88192 KB Output is correct
66 Correct 1031 ms 88044 KB Output is correct
67 Correct 1041 ms 88536 KB Output is correct
68 Correct 1076 ms 89084 KB Output is correct
69 Correct 1066 ms 89292 KB Output is correct
70 Correct 1067 ms 88644 KB Output is correct
71 Correct 1070 ms 95048 KB Output is correct
72 Correct 1062 ms 88812 KB Output is correct
73 Correct 703 ms 82932 KB Output is correct
74 Correct 709 ms 82644 KB Output is correct
75 Correct 702 ms 82540 KB Output is correct
76 Correct 713 ms 82328 KB Output is correct
77 Correct 701 ms 82848 KB Output is correct
78 Correct 961 ms 91452 KB Output is correct
79 Correct 742 ms 76892 KB Output is correct
80 Correct 979 ms 106972 KB Output is correct