Submission #874673

# Submission time Handle Problem Language Result Execution time Memory
874673 2023-11-17T14:36:50 Z 12345678 Osumnjičeni (COCI21_osumnjiceni) C++17
110 / 110
242 ms 31304 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=2e5+5, inf=2e9, kx=18;
int n, dp[nx][kx], p, q, l, r;
vector<pair<int, int>> v(nx);
multiset<pair<int, int>> ms;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n;
    for (int i=1; i<=n; i++) cin>>v[i].first>>v[i].second;
    ms.insert({-inf, -inf});
    ms.insert({inf, inf});
    for (int i=1; i<=n; i++)
    {
        while (prev(ms.upper_bound(make_pair(v[i].second, INT_MAX)))->second>=v[i].first) ++p, ms.erase(v[p]);
        dp[i][0]=p+1;
        ms.insert(v[i]);
    }
    for (int i=1; i<kx; i++) for (int j=1; j<=n; j++) dp[j][i]=dp[max(dp[j][i-1]-1, 1)][i-1];
    cin>>q;
    while (q--)
    {
        cin>>l>>r;
        int ans=0;
        for (int i=kx-1; i>=0; i--) if (dp[r][i]>l) ans+=(1<<i), r=dp[r][i]-1;
        cout<<ans+1<<'\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 51 ms 19024 KB Output is correct
2 Correct 50 ms 18772 KB Output is correct
3 Correct 56 ms 19044 KB Output is correct
4 Correct 49 ms 18920 KB Output is correct
5 Correct 52 ms 19672 KB Output is correct
6 Correct 46 ms 18152 KB Output is correct
7 Correct 49 ms 18524 KB Output is correct
8 Correct 52 ms 18516 KB Output is correct
9 Correct 67 ms 18920 KB Output is correct
10 Correct 56 ms 18260 KB Output is correct
11 Correct 120 ms 27936 KB Output is correct
12 Correct 106 ms 26592 KB Output is correct
13 Correct 114 ms 26340 KB Output is correct
14 Correct 147 ms 24240 KB Output is correct
15 Correct 124 ms 22440 KB Output is correct
16 Correct 1 ms 1880 KB Output is correct
17 Correct 58 ms 19300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4184 KB Output is correct
2 Correct 4 ms 4188 KB Output is correct
3 Correct 4 ms 4188 KB Output is correct
4 Correct 4 ms 4424 KB Output is correct
5 Correct 4 ms 4188 KB Output is correct
6 Correct 4 ms 4360 KB Output is correct
7 Correct 4 ms 4404 KB Output is correct
8 Correct 4 ms 4188 KB Output is correct
9 Correct 5 ms 4228 KB Output is correct
10 Correct 4 ms 4188 KB Output is correct
11 Correct 4 ms 4612 KB Output is correct
12 Correct 4 ms 4360 KB Output is correct
13 Correct 4 ms 4444 KB Output is correct
14 Correct 4 ms 4440 KB Output is correct
15 Correct 4 ms 4444 KB Output is correct
16 Correct 1 ms 1884 KB Output is correct
17 Correct 4 ms 4188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4184 KB Output is correct
2 Correct 4 ms 4188 KB Output is correct
3 Correct 4 ms 4188 KB Output is correct
4 Correct 4 ms 4424 KB Output is correct
5 Correct 4 ms 4188 KB Output is correct
6 Correct 4 ms 4360 KB Output is correct
7 Correct 4 ms 4404 KB Output is correct
8 Correct 4 ms 4188 KB Output is correct
9 Correct 5 ms 4228 KB Output is correct
10 Correct 4 ms 4188 KB Output is correct
11 Correct 4 ms 4612 KB Output is correct
12 Correct 4 ms 4360 KB Output is correct
13 Correct 4 ms 4444 KB Output is correct
14 Correct 4 ms 4440 KB Output is correct
15 Correct 4 ms 4444 KB Output is correct
16 Correct 1 ms 1884 KB Output is correct
17 Correct 4 ms 4188 KB Output is correct
18 Correct 58 ms 6992 KB Output is correct
19 Correct 64 ms 6700 KB Output is correct
20 Correct 57 ms 6868 KB Output is correct
21 Correct 57 ms 6620 KB Output is correct
22 Correct 54 ms 6908 KB Output is correct
23 Correct 56 ms 6740 KB Output is correct
24 Correct 54 ms 6992 KB Output is correct
25 Correct 55 ms 7040 KB Output is correct
26 Correct 58 ms 6772 KB Output is correct
27 Correct 56 ms 6740 KB Output is correct
28 Correct 38 ms 6640 KB Output is correct
29 Correct 42 ms 6736 KB Output is correct
30 Correct 40 ms 6620 KB Output is correct
31 Correct 41 ms 6484 KB Output is correct
32 Correct 39 ms 6552 KB Output is correct
33 Correct 1 ms 1880 KB Output is correct
34 Correct 43 ms 6740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 19792 KB Output is correct
2 Correct 59 ms 19552 KB Output is correct
3 Correct 49 ms 18272 KB Output is correct
4 Correct 48 ms 18004 KB Output is correct
5 Correct 56 ms 18604 KB Output is correct
6 Correct 62 ms 18404 KB Output is correct
7 Correct 56 ms 18312 KB Output is correct
8 Correct 49 ms 18256 KB Output is correct
9 Correct 50 ms 18260 KB Output is correct
10 Correct 60 ms 19304 KB Output is correct
11 Correct 110 ms 26192 KB Output is correct
12 Correct 138 ms 28752 KB Output is correct
13 Correct 105 ms 26328 KB Output is correct
14 Correct 138 ms 22380 KB Output is correct
15 Correct 139 ms 24400 KB Output is correct
16 Correct 2 ms 1884 KB Output is correct
17 Correct 47 ms 18516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 19024 KB Output is correct
2 Correct 50 ms 18772 KB Output is correct
3 Correct 56 ms 19044 KB Output is correct
4 Correct 49 ms 18920 KB Output is correct
5 Correct 52 ms 19672 KB Output is correct
6 Correct 46 ms 18152 KB Output is correct
7 Correct 49 ms 18524 KB Output is correct
8 Correct 52 ms 18516 KB Output is correct
9 Correct 67 ms 18920 KB Output is correct
10 Correct 56 ms 18260 KB Output is correct
11 Correct 120 ms 27936 KB Output is correct
12 Correct 106 ms 26592 KB Output is correct
13 Correct 114 ms 26340 KB Output is correct
14 Correct 147 ms 24240 KB Output is correct
15 Correct 124 ms 22440 KB Output is correct
16 Correct 1 ms 1880 KB Output is correct
17 Correct 58 ms 19300 KB Output is correct
18 Correct 4 ms 4184 KB Output is correct
19 Correct 4 ms 4188 KB Output is correct
20 Correct 4 ms 4188 KB Output is correct
21 Correct 4 ms 4424 KB Output is correct
22 Correct 4 ms 4188 KB Output is correct
23 Correct 4 ms 4360 KB Output is correct
24 Correct 4 ms 4404 KB Output is correct
25 Correct 4 ms 4188 KB Output is correct
26 Correct 5 ms 4228 KB Output is correct
27 Correct 4 ms 4188 KB Output is correct
28 Correct 4 ms 4612 KB Output is correct
29 Correct 4 ms 4360 KB Output is correct
30 Correct 4 ms 4444 KB Output is correct
31 Correct 4 ms 4440 KB Output is correct
32 Correct 4 ms 4444 KB Output is correct
33 Correct 1 ms 1884 KB Output is correct
34 Correct 4 ms 4188 KB Output is correct
35 Correct 58 ms 6992 KB Output is correct
36 Correct 64 ms 6700 KB Output is correct
37 Correct 57 ms 6868 KB Output is correct
38 Correct 57 ms 6620 KB Output is correct
39 Correct 54 ms 6908 KB Output is correct
40 Correct 56 ms 6740 KB Output is correct
41 Correct 54 ms 6992 KB Output is correct
42 Correct 55 ms 7040 KB Output is correct
43 Correct 58 ms 6772 KB Output is correct
44 Correct 56 ms 6740 KB Output is correct
45 Correct 38 ms 6640 KB Output is correct
46 Correct 42 ms 6736 KB Output is correct
47 Correct 40 ms 6620 KB Output is correct
48 Correct 41 ms 6484 KB Output is correct
49 Correct 39 ms 6552 KB Output is correct
50 Correct 1 ms 1880 KB Output is correct
51 Correct 43 ms 6740 KB Output is correct
52 Correct 73 ms 19792 KB Output is correct
53 Correct 59 ms 19552 KB Output is correct
54 Correct 49 ms 18272 KB Output is correct
55 Correct 48 ms 18004 KB Output is correct
56 Correct 56 ms 18604 KB Output is correct
57 Correct 62 ms 18404 KB Output is correct
58 Correct 56 ms 18312 KB Output is correct
59 Correct 49 ms 18256 KB Output is correct
60 Correct 50 ms 18260 KB Output is correct
61 Correct 60 ms 19304 KB Output is correct
62 Correct 110 ms 26192 KB Output is correct
63 Correct 138 ms 28752 KB Output is correct
64 Correct 105 ms 26328 KB Output is correct
65 Correct 138 ms 22380 KB Output is correct
66 Correct 139 ms 24400 KB Output is correct
67 Correct 2 ms 1884 KB Output is correct
68 Correct 47 ms 18516 KB Output is correct
69 Correct 242 ms 22112 KB Output is correct
70 Correct 163 ms 23044 KB Output is correct
71 Correct 161 ms 21476 KB Output is correct
72 Correct 146 ms 22680 KB Output is correct
73 Correct 152 ms 22152 KB Output is correct
74 Correct 145 ms 23184 KB Output is correct
75 Correct 157 ms 21984 KB Output is correct
76 Correct 203 ms 23448 KB Output is correct
77 Correct 134 ms 21788 KB Output is correct
78 Correct 191 ms 22140 KB Output is correct
79 Correct 162 ms 31304 KB Output is correct
80 Correct 168 ms 29264 KB Output is correct
81 Correct 163 ms 29344 KB Output is correct
82 Correct 181 ms 25732 KB Output is correct
83 Correct 206 ms 24680 KB Output is correct
84 Correct 1 ms 1884 KB Output is correct
85 Correct 108 ms 21848 KB Output is correct