Submission #1058541

# Submission time Handle Problem Language Result Execution time Memory
1058541 2024-08-14T10:44:11 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
100 / 100
470 ms 77280 KB
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long double ld;
#define pb push_back
#define pf push_front
#define fi first
#define se second
const ll mod = 1e9+7, mxn = 1e6+7;
ll bit[mxn], n, q, w[mxn], lis[mxn];
bool ans[mxn];
vector<vector<pair<pair<ll,ll>,ll>>> qx(mxn);
void upd(ll u, ll v) {while (u) {bit[u] = max(bit[u],v); u -= (u&(-u));}}
ll get(ll u) {if (!u) {return 1e18;} ll sum = 0; while (u < mxn) {sum = max(sum,bit[u]); u += (u&(-u));} return sum;}
signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // freopen("test.inp","r",stdin); freopen("test.out","w",stdout); freopen("test.err","w",stderr);
    cin >> n >> q;
    for (ll i = 1; i <= n; i++)
    {
        cin >> w[i]; lis[i] = i-1;
        while (lis[i] && w[i] >= w[lis[i]]) lis[i] = lis[lis[i]];
        // cerr << lis[i] << ' ';
    }
    for (ll i = 1; i <= q; i++)
    {
        ll l, r, c; cin >> l >> r >> c;
        qx[r].pb({{l,i},c});
    }
    for (ll i = 1; i <= n; i++)
    {
        upd(lis[i],w[lis[i]]+w[i]);
        for (pair<pair<ll,ll>,ll> j : qx[i]) ans[j.fi.se] = (get(j.fi.fi) <= j.se);
    }
    for (ll i = 1; i <= q; i++) cout << ans[i] << '\n';
}

Compilation message

sortbooks.cpp: In function 'll get(ll)':
sortbooks.cpp:14:31: warning: overflow in conversion from 'double' to 'll' {aka 'int'} changes value from '1.0e+18' to '2147483647' [-Woverflow]
   14 | ll get(ll u) {if (!u) {return 1e18;} ll sum = 0; while (u < mxn) {sum = max(sum,bit[u]); u += (u&(-u));} return sum;}
      |                               ^~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 27996 KB Output is correct
2 Correct 3 ms 30044 KB Output is correct
3 Correct 4 ms 23920 KB Output is correct
4 Correct 4 ms 30104 KB Output is correct
5 Correct 4 ms 23896 KB Output is correct
6 Correct 4 ms 23900 KB Output is correct
7 Correct 4 ms 23860 KB Output is correct
8 Correct 4 ms 29980 KB Output is correct
9 Correct 4 ms 27992 KB Output is correct
10 Correct 4 ms 23996 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 27996 KB Output is correct
2 Correct 3 ms 30044 KB Output is correct
3 Correct 4 ms 23920 KB Output is correct
4 Correct 4 ms 30104 KB Output is correct
5 Correct 4 ms 23896 KB Output is correct
6 Correct 4 ms 23900 KB Output is correct
7 Correct 4 ms 23860 KB Output is correct
8 Correct 4 ms 29980 KB Output is correct
9 Correct 4 ms 27992 KB Output is correct
10 Correct 4 ms 23996 KB Output is correct
11 Correct 5 ms 23896 KB Output is correct
12 Correct 5 ms 24156 KB Output is correct
13 Correct 5 ms 24156 KB Output is correct
14 Correct 6 ms 30304 KB Output is correct
15 Correct 5 ms 26204 KB Output is correct
16 Correct 5 ms 28248 KB Output is correct
17 Correct 5 ms 24156 KB Output is correct
18 Correct 5 ms 24224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 469 ms 76540 KB Output is correct
2 Correct 465 ms 77280 KB Output is correct
3 Correct 452 ms 77004 KB Output is correct
4 Correct 470 ms 77032 KB Output is correct
5 Correct 436 ms 73628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 29260 KB Output is correct
2 Correct 32 ms 29072 KB Output is correct
3 Correct 31 ms 30544 KB Output is correct
4 Correct 32 ms 30544 KB Output is correct
5 Correct 31 ms 30592 KB Output is correct
6 Correct 25 ms 31828 KB Output is correct
7 Correct 27 ms 30292 KB Output is correct
8 Correct 30 ms 30360 KB Output is correct
9 Correct 23 ms 32780 KB Output is correct
10 Correct 32 ms 28252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 27996 KB Output is correct
2 Correct 3 ms 30044 KB Output is correct
3 Correct 4 ms 23920 KB Output is correct
4 Correct 4 ms 30104 KB Output is correct
5 Correct 4 ms 23896 KB Output is correct
6 Correct 4 ms 23900 KB Output is correct
7 Correct 4 ms 23860 KB Output is correct
8 Correct 4 ms 29980 KB Output is correct
9 Correct 4 ms 27992 KB Output is correct
10 Correct 4 ms 23996 KB Output is correct
11 Correct 5 ms 23896 KB Output is correct
12 Correct 5 ms 24156 KB Output is correct
13 Correct 5 ms 24156 KB Output is correct
14 Correct 6 ms 30304 KB Output is correct
15 Correct 5 ms 26204 KB Output is correct
16 Correct 5 ms 28248 KB Output is correct
17 Correct 5 ms 24156 KB Output is correct
18 Correct 5 ms 24224 KB Output is correct
19 Correct 76 ms 35408 KB Output is correct
20 Correct 76 ms 37296 KB Output is correct
21 Correct 69 ms 35664 KB Output is correct
22 Correct 68 ms 36948 KB Output is correct
23 Correct 67 ms 36948 KB Output is correct
24 Correct 60 ms 35212 KB Output is correct
25 Correct 63 ms 36692 KB Output is correct
26 Correct 67 ms 37020 KB Output is correct
27 Correct 67 ms 37200 KB Output is correct
28 Correct 69 ms 37204 KB Output is correct
29 Correct 79 ms 38740 KB Output is correct
30 Correct 71 ms 36184 KB Output is correct
31 Correct 71 ms 37348 KB Output is correct
32 Correct 77 ms 37536 KB Output is correct
33 Correct 69 ms 38504 KB Output is correct
34 Correct 62 ms 36180 KB Output is correct
35 Correct 57 ms 36176 KB Output is correct
36 Correct 56 ms 37588 KB Output is correct
37 Correct 56 ms 34932 KB Output is correct
38 Correct 60 ms 33080 KB Output is correct
39 Correct 65 ms 33200 KB Output is correct
40 Correct 57 ms 35344 KB Output is correct
41 Correct 66 ms 33252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 27996 KB Output is correct
2 Correct 3 ms 30044 KB Output is correct
3 Correct 4 ms 23920 KB Output is correct
4 Correct 4 ms 30104 KB Output is correct
5 Correct 4 ms 23896 KB Output is correct
6 Correct 4 ms 23900 KB Output is correct
7 Correct 4 ms 23860 KB Output is correct
8 Correct 4 ms 29980 KB Output is correct
9 Correct 4 ms 27992 KB Output is correct
10 Correct 4 ms 23996 KB Output is correct
11 Correct 5 ms 23896 KB Output is correct
12 Correct 5 ms 24156 KB Output is correct
13 Correct 5 ms 24156 KB Output is correct
14 Correct 6 ms 30304 KB Output is correct
15 Correct 5 ms 26204 KB Output is correct
16 Correct 5 ms 28248 KB Output is correct
17 Correct 5 ms 24156 KB Output is correct
18 Correct 5 ms 24224 KB Output is correct
19 Correct 469 ms 76540 KB Output is correct
20 Correct 465 ms 77280 KB Output is correct
21 Correct 452 ms 77004 KB Output is correct
22 Correct 470 ms 77032 KB Output is correct
23 Correct 436 ms 73628 KB Output is correct
24 Correct 33 ms 29260 KB Output is correct
25 Correct 32 ms 29072 KB Output is correct
26 Correct 31 ms 30544 KB Output is correct
27 Correct 32 ms 30544 KB Output is correct
28 Correct 31 ms 30592 KB Output is correct
29 Correct 25 ms 31828 KB Output is correct
30 Correct 27 ms 30292 KB Output is correct
31 Correct 30 ms 30360 KB Output is correct
32 Correct 23 ms 32780 KB Output is correct
33 Correct 32 ms 28252 KB Output is correct
34 Correct 76 ms 35408 KB Output is correct
35 Correct 76 ms 37296 KB Output is correct
36 Correct 69 ms 35664 KB Output is correct
37 Correct 68 ms 36948 KB Output is correct
38 Correct 67 ms 36948 KB Output is correct
39 Correct 60 ms 35212 KB Output is correct
40 Correct 63 ms 36692 KB Output is correct
41 Correct 67 ms 37020 KB Output is correct
42 Correct 67 ms 37200 KB Output is correct
43 Correct 69 ms 37204 KB Output is correct
44 Correct 79 ms 38740 KB Output is correct
45 Correct 71 ms 36184 KB Output is correct
46 Correct 71 ms 37348 KB Output is correct
47 Correct 77 ms 37536 KB Output is correct
48 Correct 69 ms 38504 KB Output is correct
49 Correct 62 ms 36180 KB Output is correct
50 Correct 57 ms 36176 KB Output is correct
51 Correct 56 ms 37588 KB Output is correct
52 Correct 56 ms 34932 KB Output is correct
53 Correct 60 ms 33080 KB Output is correct
54 Correct 65 ms 33200 KB Output is correct
55 Correct 57 ms 35344 KB Output is correct
56 Correct 66 ms 33252 KB Output is correct
57 Correct 453 ms 76880 KB Output is correct
58 Correct 439 ms 77036 KB Output is correct
59 Correct 406 ms 58452 KB Output is correct
60 Correct 375 ms 58196 KB Output is correct
61 Correct 384 ms 58192 KB Output is correct
62 Correct 377 ms 58196 KB Output is correct
63 Correct 279 ms 54612 KB Output is correct
64 Correct 286 ms 54744 KB Output is correct
65 Correct 364 ms 55820 KB Output is correct
66 Correct 353 ms 55892 KB Output is correct
67 Correct 390 ms 56008 KB Output is correct
68 Correct 395 ms 57424 KB Output is correct
69 Correct 388 ms 57424 KB Output is correct
70 Correct 420 ms 57216 KB Output is correct
71 Correct 426 ms 57180 KB Output is correct
72 Correct 393 ms 57296 KB Output is correct
73 Correct 262 ms 52044 KB Output is correct
74 Correct 256 ms 51996 KB Output is correct
75 Correct 263 ms 52308 KB Output is correct
76 Correct 247 ms 52212 KB Output is correct
77 Correct 278 ms 51792 KB Output is correct
78 Correct 348 ms 56580 KB Output is correct
79 Correct 300 ms 50680 KB Output is correct
80 Correct 338 ms 55796 KB Output is correct