# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1022928 | 2024-07-14T07:40:40 Z | hasan2006 | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++17 | 757 ms | 153604 KB |
#include <bits/stdc++.h> using namespace std; #define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define rall(s) s.rbegin(),s.rend() #define all(s) s.begin(),s.end() #define pb push_back #define se second #define fi first #define ll long long #define ld long double #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define yes cout<<"yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define no cout<<"no\n" const int N = 1e6 + 9 , mod = 1e9 + 7; ll a[N] , b[N] , dp[N] , c[N] , d[N] , ans[N] ; vector<int>vc[N]; void add(int x , ll y){ while(x <= 1000000){ dp[x] = max(dp[x] , y); x += (x & -x); } } ll get(int x ){ ll ans = 0; while(x > 0){ ans = max(dp[x] , ans); x -= (x & -x); } return ans; } void solve() { ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ; cin>>n>>m; vector<pair<int,int>>v; set<pair<int,int>>st; for(i = 1; i <= n; i++) cin>>d[i]; for(i = n; i >= 1; i--){ while(st.size() && st.begin()->fi < d[i]) vc[i].pb(st.begin()->se), st.erase(st.begin()); st.insert({d[i] , i}); } for(i = 1; i <= m; i++){ cin>>a[i]>>b[i]>>c[i]; v.pb({a[i] , i}); } sort(rall(v)); r = n; for(auto to : v){ i = to.se; while(r >= a[i]){ for(auto x : vc[r]) add(x , d[x] + d[r]); r--; } ans[i] = (get(b[i]) <= c[i]); } for(i = 1; i <= m; i++) cout<<ans[i]<<"\n"; } int main(){ TL; /*#ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif*/ int t = 1; // cin>>t; while(t--) { solve(); } } // Author : حسن
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 23896 KB | Output is correct |
2 | Correct | 11 ms | 23900 KB | Output is correct |
3 | Correct | 11 ms | 23896 KB | Output is correct |
4 | Correct | 13 ms | 23900 KB | Output is correct |
5 | Correct | 11 ms | 23900 KB | Output is correct |
6 | Correct | 11 ms | 23868 KB | Output is correct |
7 | Correct | 11 ms | 23976 KB | Output is correct |
8 | Correct | 11 ms | 23900 KB | Output is correct |
9 | Correct | 12 ms | 23956 KB | Output is correct |
10 | Correct | 12 ms | 23900 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 23896 KB | Output is correct |
2 | Correct | 11 ms | 23900 KB | Output is correct |
3 | Correct | 11 ms | 23896 KB | Output is correct |
4 | Correct | 13 ms | 23900 KB | Output is correct |
5 | Correct | 11 ms | 23900 KB | Output is correct |
6 | Correct | 11 ms | 23868 KB | Output is correct |
7 | Correct | 11 ms | 23976 KB | Output is correct |
8 | Correct | 11 ms | 23900 KB | Output is correct |
9 | Correct | 12 ms | 23956 KB | Output is correct |
10 | Correct | 12 ms | 23900 KB | Output is correct |
11 | Correct | 12 ms | 24152 KB | Output is correct |
12 | Correct | 14 ms | 24412 KB | Output is correct |
13 | Correct | 15 ms | 24420 KB | Output is correct |
14 | Correct | 14 ms | 24412 KB | Output is correct |
15 | Correct | 14 ms | 24480 KB | Output is correct |
16 | Correct | 13 ms | 24412 KB | Output is correct |
17 | Correct | 12 ms | 24600 KB | Output is correct |
18 | Correct | 14 ms | 24496 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 641 ms | 97144 KB | Output is correct |
2 | Correct | 643 ms | 96972 KB | Output is correct |
3 | Correct | 640 ms | 97020 KB | Output is correct |
4 | Correct | 648 ms | 96940 KB | Output is correct |
5 | Correct | 676 ms | 119984 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 61 ms | 31432 KB | Output is correct |
2 | Correct | 60 ms | 33476 KB | Output is correct |
3 | Correct | 64 ms | 35528 KB | Output is correct |
4 | Correct | 70 ms | 35644 KB | Output is correct |
5 | Correct | 64 ms | 35524 KB | Output is correct |
6 | Correct | 61 ms | 35012 KB | Output is correct |
7 | Correct | 63 ms | 35072 KB | Output is correct |
8 | Correct | 60 ms | 33092 KB | Output is correct |
9 | Correct | 43 ms | 29616 KB | Output is correct |
10 | Correct | 59 ms | 33224 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 23896 KB | Output is correct |
2 | Correct | 11 ms | 23900 KB | Output is correct |
3 | Correct | 11 ms | 23896 KB | Output is correct |
4 | Correct | 13 ms | 23900 KB | Output is correct |
5 | Correct | 11 ms | 23900 KB | Output is correct |
6 | Correct | 11 ms | 23868 KB | Output is correct |
7 | Correct | 11 ms | 23976 KB | Output is correct |
8 | Correct | 11 ms | 23900 KB | Output is correct |
9 | Correct | 12 ms | 23956 KB | Output is correct |
10 | Correct | 12 ms | 23900 KB | Output is correct |
11 | Correct | 12 ms | 24152 KB | Output is correct |
12 | Correct | 14 ms | 24412 KB | Output is correct |
13 | Correct | 15 ms | 24420 KB | Output is correct |
14 | Correct | 14 ms | 24412 KB | Output is correct |
15 | Correct | 14 ms | 24480 KB | Output is correct |
16 | Correct | 13 ms | 24412 KB | Output is correct |
17 | Correct | 12 ms | 24600 KB | Output is correct |
18 | Correct | 14 ms | 24496 KB | Output is correct |
19 | Correct | 131 ms | 45248 KB | Output is correct |
20 | Correct | 123 ms | 45224 KB | Output is correct |
21 | Correct | 127 ms | 44996 KB | Output is correct |
22 | Correct | 121 ms | 44992 KB | Output is correct |
23 | Correct | 120 ms | 44988 KB | Output is correct |
24 | Correct | 131 ms | 49604 KB | Output is correct |
25 | Correct | 130 ms | 49624 KB | Output is correct |
26 | Correct | 133 ms | 49632 KB | Output is correct |
27 | Correct | 141 ms | 49604 KB | Output is correct |
28 | Correct | 134 ms | 49624 KB | Output is correct |
29 | Correct | 134 ms | 49720 KB | Output is correct |
30 | Correct | 134 ms | 49852 KB | Output is correct |
31 | Correct | 167 ms | 49856 KB | Output is correct |
32 | Correct | 137 ms | 49648 KB | Output is correct |
33 | Correct | 133 ms | 49744 KB | Output is correct |
34 | Correct | 126 ms | 49436 KB | Output is correct |
35 | Correct | 125 ms | 49440 KB | Output is correct |
36 | Correct | 126 ms | 49600 KB | Output is correct |
37 | Correct | 126 ms | 49344 KB | Output is correct |
38 | Correct | 127 ms | 49340 KB | Output is correct |
39 | Correct | 122 ms | 46780 KB | Output is correct |
40 | Correct | 103 ms | 42692 KB | Output is correct |
41 | Correct | 127 ms | 44220 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 23896 KB | Output is correct |
2 | Correct | 11 ms | 23900 KB | Output is correct |
3 | Correct | 11 ms | 23896 KB | Output is correct |
4 | Correct | 13 ms | 23900 KB | Output is correct |
5 | Correct | 11 ms | 23900 KB | Output is correct |
6 | Correct | 11 ms | 23868 KB | Output is correct |
7 | Correct | 11 ms | 23976 KB | Output is correct |
8 | Correct | 11 ms | 23900 KB | Output is correct |
9 | Correct | 12 ms | 23956 KB | Output is correct |
10 | Correct | 12 ms | 23900 KB | Output is correct |
11 | Correct | 12 ms | 24152 KB | Output is correct |
12 | Correct | 14 ms | 24412 KB | Output is correct |
13 | Correct | 15 ms | 24420 KB | Output is correct |
14 | Correct | 14 ms | 24412 KB | Output is correct |
15 | Correct | 14 ms | 24480 KB | Output is correct |
16 | Correct | 13 ms | 24412 KB | Output is correct |
17 | Correct | 12 ms | 24600 KB | Output is correct |
18 | Correct | 14 ms | 24496 KB | Output is correct |
19 | Correct | 641 ms | 97144 KB | Output is correct |
20 | Correct | 643 ms | 96972 KB | Output is correct |
21 | Correct | 640 ms | 97020 KB | Output is correct |
22 | Correct | 648 ms | 96940 KB | Output is correct |
23 | Correct | 676 ms | 119984 KB | Output is correct |
24 | Correct | 61 ms | 31432 KB | Output is correct |
25 | Correct | 60 ms | 33476 KB | Output is correct |
26 | Correct | 64 ms | 35528 KB | Output is correct |
27 | Correct | 70 ms | 35644 KB | Output is correct |
28 | Correct | 64 ms | 35524 KB | Output is correct |
29 | Correct | 61 ms | 35012 KB | Output is correct |
30 | Correct | 63 ms | 35072 KB | Output is correct |
31 | Correct | 60 ms | 33092 KB | Output is correct |
32 | Correct | 43 ms | 29616 KB | Output is correct |
33 | Correct | 59 ms | 33224 KB | Output is correct |
34 | Correct | 131 ms | 45248 KB | Output is correct |
35 | Correct | 123 ms | 45224 KB | Output is correct |
36 | Correct | 127 ms | 44996 KB | Output is correct |
37 | Correct | 121 ms | 44992 KB | Output is correct |
38 | Correct | 120 ms | 44988 KB | Output is correct |
39 | Correct | 131 ms | 49604 KB | Output is correct |
40 | Correct | 130 ms | 49624 KB | Output is correct |
41 | Correct | 133 ms | 49632 KB | Output is correct |
42 | Correct | 141 ms | 49604 KB | Output is correct |
43 | Correct | 134 ms | 49624 KB | Output is correct |
44 | Correct | 134 ms | 49720 KB | Output is correct |
45 | Correct | 134 ms | 49852 KB | Output is correct |
46 | Correct | 167 ms | 49856 KB | Output is correct |
47 | Correct | 137 ms | 49648 KB | Output is correct |
48 | Correct | 133 ms | 49744 KB | Output is correct |
49 | Correct | 126 ms | 49436 KB | Output is correct |
50 | Correct | 125 ms | 49440 KB | Output is correct |
51 | Correct | 126 ms | 49600 KB | Output is correct |
52 | Correct | 126 ms | 49344 KB | Output is correct |
53 | Correct | 127 ms | 49340 KB | Output is correct |
54 | Correct | 122 ms | 46780 KB | Output is correct |
55 | Correct | 103 ms | 42692 KB | Output is correct |
56 | Correct | 127 ms | 44220 KB | Output is correct |
57 | Correct | 652 ms | 130476 KB | Output is correct |
58 | Correct | 687 ms | 130660 KB | Output is correct |
59 | Correct | 623 ms | 130372 KB | Output is correct |
60 | Correct | 666 ms | 130540 KB | Output is correct |
61 | Correct | 635 ms | 130468 KB | Output is correct |
62 | Correct | 661 ms | 130556 KB | Output is correct |
63 | Correct | 670 ms | 151472 KB | Output is correct |
64 | Correct | 697 ms | 151504 KB | Output is correct |
65 | Correct | 729 ms | 153360 KB | Output is correct |
66 | Correct | 735 ms | 153364 KB | Output is correct |
67 | Correct | 751 ms | 153340 KB | Output is correct |
68 | Correct | 690 ms | 153520 KB | Output is correct |
69 | Correct | 703 ms | 153604 KB | Output is correct |
70 | Correct | 701 ms | 153532 KB | Output is correct |
71 | Correct | 757 ms | 153520 KB | Output is correct |
72 | Correct | 749 ms | 153532 KB | Output is correct |
73 | Correct | 681 ms | 150264 KB | Output is correct |
74 | Correct | 654 ms | 150960 KB | Output is correct |
75 | Correct | 657 ms | 150188 KB | Output is correct |
76 | Correct | 664 ms | 150196 KB | Output is correct |
77 | Correct | 673 ms | 149984 KB | Output is correct |
78 | Correct | 648 ms | 139732 KB | Output is correct |
79 | Correct | 487 ms | 112044 KB | Output is correct |
80 | Correct | 644 ms | 127620 KB | Output is correct |