Submission #1058536

# Submission time Handle Problem Language Result Execution time Memory
1058536 2024-08-14T10:42:05 Z _shr104 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
100 / 100
573 ms 75484 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 4 ms 23896 KB Output is correct
2 Correct 4 ms 23900 KB Output is correct
3 Correct 4 ms 23900 KB Output is correct
4 Correct 4 ms 23788 KB Output is correct
5 Correct 3 ms 23832 KB Output is correct
6 Correct 4 ms 23900 KB Output is correct
7 Correct 4 ms 23896 KB Output is correct
8 Correct 4 ms 23900 KB Output is correct
9 Correct 4 ms 23900 KB Output is correct
10 Correct 4 ms 23900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 23896 KB Output is correct
2 Correct 4 ms 23900 KB Output is correct
3 Correct 4 ms 23900 KB Output is correct
4 Correct 4 ms 23788 KB Output is correct
5 Correct 3 ms 23832 KB Output is correct
6 Correct 4 ms 23900 KB Output is correct
7 Correct 4 ms 23896 KB Output is correct
8 Correct 4 ms 23900 KB Output is correct
9 Correct 4 ms 23900 KB Output is correct
10 Correct 4 ms 23900 KB Output is correct
11 Correct 4 ms 23900 KB Output is correct
12 Correct 5 ms 23900 KB Output is correct
13 Correct 5 ms 23900 KB Output is correct
14 Correct 8 ms 24156 KB Output is correct
15 Correct 5 ms 24156 KB Output is correct
16 Correct 6 ms 24152 KB Output is correct
17 Correct 5 ms 23900 KB Output is correct
18 Correct 6 ms 24156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 474 ms 60360 KB Output is correct
2 Correct 434 ms 60248 KB Output is correct
3 Correct 451 ms 60480 KB Output is correct
4 Correct 442 ms 60240 KB Output is correct
5 Correct 395 ms 56300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 27476 KB Output is correct
2 Correct 31 ms 27224 KB Output is correct
3 Correct 32 ms 26964 KB Output is correct
4 Correct 31 ms 26964 KB Output is correct
5 Correct 32 ms 26972 KB Output is correct
6 Correct 27 ms 26536 KB Output is correct
7 Correct 32 ms 26708 KB Output is correct
8 Correct 32 ms 27028 KB Output is correct
9 Correct 27 ms 25564 KB Output is correct
10 Correct 32 ms 27024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 23896 KB Output is correct
2 Correct 4 ms 23900 KB Output is correct
3 Correct 4 ms 23900 KB Output is correct
4 Correct 4 ms 23788 KB Output is correct
5 Correct 3 ms 23832 KB Output is correct
6 Correct 4 ms 23900 KB Output is correct
7 Correct 4 ms 23896 KB Output is correct
8 Correct 4 ms 23900 KB Output is correct
9 Correct 4 ms 23900 KB Output is correct
10 Correct 4 ms 23900 KB Output is correct
11 Correct 4 ms 23900 KB Output is correct
12 Correct 5 ms 23900 KB Output is correct
13 Correct 5 ms 23900 KB Output is correct
14 Correct 8 ms 24156 KB Output is correct
15 Correct 5 ms 24156 KB Output is correct
16 Correct 6 ms 24152 KB Output is correct
17 Correct 5 ms 23900 KB Output is correct
18 Correct 6 ms 24156 KB Output is correct
19 Correct 74 ms 30932 KB Output is correct
20 Correct 73 ms 31060 KB Output is correct
21 Correct 63 ms 30548 KB Output is correct
22 Correct 64 ms 30548 KB Output is correct
23 Correct 65 ms 30460 KB Output is correct
24 Correct 68 ms 29652 KB Output is correct
25 Correct 62 ms 29780 KB Output is correct
26 Correct 68 ms 29780 KB Output is correct
27 Correct 64 ms 29780 KB Output is correct
28 Correct 64 ms 29948 KB Output is correct
29 Correct 73 ms 30288 KB Output is correct
30 Correct 71 ms 30348 KB Output is correct
31 Correct 69 ms 30252 KB Output is correct
32 Correct 69 ms 30288 KB Output is correct
33 Correct 71 ms 30308 KB Output is correct
34 Correct 65 ms 29520 KB Output is correct
35 Correct 59 ms 29264 KB Output is correct
36 Correct 63 ms 29392 KB Output is correct
37 Correct 66 ms 29268 KB Output is correct
38 Correct 58 ms 29280 KB Output is correct
39 Correct 63 ms 32008 KB Output is correct
40 Correct 61 ms 30984 KB Output is correct
41 Correct 66 ms 29880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 23896 KB Output is correct
2 Correct 4 ms 23900 KB Output is correct
3 Correct 4 ms 23900 KB Output is correct
4 Correct 4 ms 23788 KB Output is correct
5 Correct 3 ms 23832 KB Output is correct
6 Correct 4 ms 23900 KB Output is correct
7 Correct 4 ms 23896 KB Output is correct
8 Correct 4 ms 23900 KB Output is correct
9 Correct 4 ms 23900 KB Output is correct
10 Correct 4 ms 23900 KB Output is correct
11 Correct 4 ms 23900 KB Output is correct
12 Correct 5 ms 23900 KB Output is correct
13 Correct 5 ms 23900 KB Output is correct
14 Correct 8 ms 24156 KB Output is correct
15 Correct 5 ms 24156 KB Output is correct
16 Correct 6 ms 24152 KB Output is correct
17 Correct 5 ms 23900 KB Output is correct
18 Correct 6 ms 24156 KB Output is correct
19 Correct 474 ms 60360 KB Output is correct
20 Correct 434 ms 60248 KB Output is correct
21 Correct 451 ms 60480 KB Output is correct
22 Correct 442 ms 60240 KB Output is correct
23 Correct 395 ms 56300 KB Output is correct
24 Correct 34 ms 27476 KB Output is correct
25 Correct 31 ms 27224 KB Output is correct
26 Correct 32 ms 26964 KB Output is correct
27 Correct 31 ms 26964 KB Output is correct
28 Correct 32 ms 26972 KB Output is correct
29 Correct 27 ms 26536 KB Output is correct
30 Correct 32 ms 26708 KB Output is correct
31 Correct 32 ms 27028 KB Output is correct
32 Correct 27 ms 25564 KB Output is correct
33 Correct 32 ms 27024 KB Output is correct
34 Correct 74 ms 30932 KB Output is correct
35 Correct 73 ms 31060 KB Output is correct
36 Correct 63 ms 30548 KB Output is correct
37 Correct 64 ms 30548 KB Output is correct
38 Correct 65 ms 30460 KB Output is correct
39 Correct 68 ms 29652 KB Output is correct
40 Correct 62 ms 29780 KB Output is correct
41 Correct 68 ms 29780 KB Output is correct
42 Correct 64 ms 29780 KB Output is correct
43 Correct 64 ms 29948 KB Output is correct
44 Correct 73 ms 30288 KB Output is correct
45 Correct 71 ms 30348 KB Output is correct
46 Correct 69 ms 30252 KB Output is correct
47 Correct 69 ms 30288 KB Output is correct
48 Correct 71 ms 30308 KB Output is correct
49 Correct 65 ms 29520 KB Output is correct
50 Correct 59 ms 29264 KB Output is correct
51 Correct 63 ms 29392 KB Output is correct
52 Correct 66 ms 29268 KB Output is correct
53 Correct 58 ms 29280 KB Output is correct
54 Correct 63 ms 32008 KB Output is correct
55 Correct 61 ms 30984 KB Output is correct
56 Correct 66 ms 29880 KB Output is correct
57 Correct 526 ms 59744 KB Output is correct
58 Correct 573 ms 59640 KB Output is correct
59 Correct 523 ms 75352 KB Output is correct
60 Correct 561 ms 75484 KB Output is correct
61 Correct 468 ms 75400 KB Output is correct
62 Correct 468 ms 75464 KB Output is correct
63 Correct 314 ms 70848 KB Output is correct
64 Correct 291 ms 70700 KB Output is correct
65 Correct 393 ms 73072 KB Output is correct
66 Correct 397 ms 73116 KB Output is correct
67 Correct 357 ms 73044 KB Output is correct
68 Correct 443 ms 74580 KB Output is correct
69 Correct 409 ms 74576 KB Output is correct
70 Correct 431 ms 74232 KB Output is correct
71 Correct 415 ms 74348 KB Output is correct
72 Correct 412 ms 74320 KB Output is correct
73 Correct 260 ms 67416 KB Output is correct
74 Correct 263 ms 67924 KB Output is correct
75 Correct 268 ms 67404 KB Output is correct
76 Correct 275 ms 67716 KB Output is correct
77 Correct 255 ms 67156 KB Output is correct
78 Correct 364 ms 70760 KB Output is correct
79 Correct 280 ms 63960 KB Output is correct
80 Correct 380 ms 68356 KB Output is correct