Submission #1094878

# Submission time Handle Problem Language Result Execution time Memory
1094878 2024-09-30T17:49:14 Z Kerim Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
100 / 100
604 ms 93804 KB
#include "bits/stdc++.h"
#define MAXN 1000009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;
 
typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int F[MAXN],arr[MAXN],k[MAXN],ans[MAXN];
vector<PII>adj[MAXN];
void upd(int x,int val){
	for(;x;x-=x&(-x))
		umax(F[x],val);	
}
int tap(int x){
	int res=0;
	for(;x<MAXN;x+=x&(-x))
		umax(res,F[x]);
	return res;
}
int main(){
 //   freopen("file.in", "r", stdin);
    int n,q;
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++)
    	scanf("%d",arr+i);
    for(int i=1;i<=q;i++){
   		int l,r;
		scanf("%d%d%d",&l,&r,&k[i]);
		adj[r].pb(mp(l,i));	
    }
    stack<int>st;
	for(int i=1;i<=n;i++){
		while(!st.empty() and arr[st.top()]<=arr[i])
			st.pop();
		if(!st.empty())
			upd(st.top(),arr[st.top()]+arr[i]);
		tr(it,adj[i])
			if(tap(it->ff)<=k[it->ss])
				ans[it->ss]=1;
		st.push(i);
	}
	for(int i=1;i<=q;i++)
		printf("%d\n",ans[i]);
	return 0;
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |     scanf("%d%d",&n,&q);
      |     ~~~~~^~~~~~~~~~~~~~
sortbooks.cpp:37:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |      scanf("%d",arr+i);
      |      ~~~~~^~~~~~~~~~~~
sortbooks.cpp:40:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |   scanf("%d%d%d",&l,&r,&k[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 23900 KB Output is correct
2 Correct 9 ms 23888 KB Output is correct
3 Correct 10 ms 23932 KB Output is correct
4 Correct 9 ms 23900 KB Output is correct
5 Correct 10 ms 23860 KB Output is correct
6 Correct 10 ms 23900 KB Output is correct
7 Correct 9 ms 23848 KB Output is correct
8 Correct 10 ms 23900 KB Output is correct
9 Correct 10 ms 23900 KB Output is correct
10 Correct 10 ms 23868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 23900 KB Output is correct
2 Correct 9 ms 23888 KB Output is correct
3 Correct 10 ms 23932 KB Output is correct
4 Correct 9 ms 23900 KB Output is correct
5 Correct 10 ms 23860 KB Output is correct
6 Correct 10 ms 23900 KB Output is correct
7 Correct 9 ms 23848 KB Output is correct
8 Correct 10 ms 23900 KB Output is correct
9 Correct 10 ms 23900 KB Output is correct
10 Correct 10 ms 23868 KB Output is correct
11 Correct 11 ms 23896 KB Output is correct
12 Correct 11 ms 24156 KB Output is correct
13 Correct 11 ms 24048 KB Output is correct
14 Correct 12 ms 24152 KB Output is correct
15 Correct 12 ms 24156 KB Output is correct
16 Correct 12 ms 24408 KB Output is correct
17 Correct 13 ms 24156 KB Output is correct
18 Correct 11 ms 24156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 575 ms 81704 KB Output is correct
2 Correct 576 ms 90200 KB Output is correct
3 Correct 604 ms 90196 KB Output is correct
4 Correct 594 ms 90192 KB Output is correct
5 Correct 537 ms 90192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 29520 KB Output is correct
2 Correct 48 ms 28980 KB Output is correct
3 Correct 47 ms 28756 KB Output is correct
4 Correct 52 ms 29012 KB Output is correct
5 Correct 47 ms 29024 KB Output is correct
6 Correct 42 ms 27740 KB Output is correct
7 Correct 41 ms 27732 KB Output is correct
8 Correct 48 ms 28508 KB Output is correct
9 Correct 33 ms 27080 KB Output is correct
10 Correct 46 ms 28620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 23900 KB Output is correct
2 Correct 9 ms 23888 KB Output is correct
3 Correct 10 ms 23932 KB Output is correct
4 Correct 9 ms 23900 KB Output is correct
5 Correct 10 ms 23860 KB Output is correct
6 Correct 10 ms 23900 KB Output is correct
7 Correct 9 ms 23848 KB Output is correct
8 Correct 10 ms 23900 KB Output is correct
9 Correct 10 ms 23900 KB Output is correct
10 Correct 10 ms 23868 KB Output is correct
11 Correct 11 ms 23896 KB Output is correct
12 Correct 11 ms 24156 KB Output is correct
13 Correct 11 ms 24048 KB Output is correct
14 Correct 12 ms 24152 KB Output is correct
15 Correct 12 ms 24156 KB Output is correct
16 Correct 12 ms 24408 KB Output is correct
17 Correct 13 ms 24156 KB Output is correct
18 Correct 11 ms 24156 KB Output is correct
19 Correct 100 ms 37716 KB Output is correct
20 Correct 102 ms 37592 KB Output is correct
21 Correct 90 ms 36436 KB Output is correct
22 Correct 94 ms 36420 KB Output is correct
23 Correct 90 ms 36432 KB Output is correct
24 Correct 79 ms 35368 KB Output is correct
25 Correct 88 ms 35412 KB Output is correct
26 Correct 85 ms 36180 KB Output is correct
27 Correct 88 ms 35924 KB Output is correct
28 Correct 86 ms 36180 KB Output is correct
29 Correct 93 ms 36764 KB Output is correct
30 Correct 93 ms 36944 KB Output is correct
31 Correct 95 ms 36948 KB Output is correct
32 Correct 94 ms 36944 KB Output is correct
33 Correct 97 ms 36772 KB Output is correct
34 Correct 83 ms 35152 KB Output is correct
35 Correct 89 ms 35028 KB Output is correct
36 Correct 82 ms 34908 KB Output is correct
37 Correct 84 ms 34924 KB Output is correct
38 Correct 84 ms 34896 KB Output is correct
39 Correct 91 ms 35272 KB Output is correct
40 Correct 78 ms 33732 KB Output is correct
41 Correct 88 ms 34760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 23900 KB Output is correct
2 Correct 9 ms 23888 KB Output is correct
3 Correct 10 ms 23932 KB Output is correct
4 Correct 9 ms 23900 KB Output is correct
5 Correct 10 ms 23860 KB Output is correct
6 Correct 10 ms 23900 KB Output is correct
7 Correct 9 ms 23848 KB Output is correct
8 Correct 10 ms 23900 KB Output is correct
9 Correct 10 ms 23900 KB Output is correct
10 Correct 10 ms 23868 KB Output is correct
11 Correct 11 ms 23896 KB Output is correct
12 Correct 11 ms 24156 KB Output is correct
13 Correct 11 ms 24048 KB Output is correct
14 Correct 12 ms 24152 KB Output is correct
15 Correct 12 ms 24156 KB Output is correct
16 Correct 12 ms 24408 KB Output is correct
17 Correct 13 ms 24156 KB Output is correct
18 Correct 11 ms 24156 KB Output is correct
19 Correct 575 ms 81704 KB Output is correct
20 Correct 576 ms 90200 KB Output is correct
21 Correct 604 ms 90196 KB Output is correct
22 Correct 594 ms 90192 KB Output is correct
23 Correct 537 ms 90192 KB Output is correct
24 Correct 49 ms 29520 KB Output is correct
25 Correct 48 ms 28980 KB Output is correct
26 Correct 47 ms 28756 KB Output is correct
27 Correct 52 ms 29012 KB Output is correct
28 Correct 47 ms 29024 KB Output is correct
29 Correct 42 ms 27740 KB Output is correct
30 Correct 41 ms 27732 KB Output is correct
31 Correct 48 ms 28508 KB Output is correct
32 Correct 33 ms 27080 KB Output is correct
33 Correct 46 ms 28620 KB Output is correct
34 Correct 100 ms 37716 KB Output is correct
35 Correct 102 ms 37592 KB Output is correct
36 Correct 90 ms 36436 KB Output is correct
37 Correct 94 ms 36420 KB Output is correct
38 Correct 90 ms 36432 KB Output is correct
39 Correct 79 ms 35368 KB Output is correct
40 Correct 88 ms 35412 KB Output is correct
41 Correct 85 ms 36180 KB Output is correct
42 Correct 88 ms 35924 KB Output is correct
43 Correct 86 ms 36180 KB Output is correct
44 Correct 93 ms 36764 KB Output is correct
45 Correct 93 ms 36944 KB Output is correct
46 Correct 95 ms 36948 KB Output is correct
47 Correct 94 ms 36944 KB Output is correct
48 Correct 97 ms 36772 KB Output is correct
49 Correct 83 ms 35152 KB Output is correct
50 Correct 89 ms 35028 KB Output is correct
51 Correct 82 ms 34908 KB Output is correct
52 Correct 84 ms 34924 KB Output is correct
53 Correct 84 ms 34896 KB Output is correct
54 Correct 91 ms 35272 KB Output is correct
55 Correct 78 ms 33732 KB Output is correct
56 Correct 88 ms 34760 KB Output is correct
57 Correct 590 ms 93628 KB Output is correct
58 Correct 584 ms 93804 KB Output is correct
59 Correct 521 ms 90960 KB Output is correct
60 Correct 497 ms 90800 KB Output is correct
61 Correct 498 ms 90860 KB Output is correct
62 Correct 541 ms 90788 KB Output is correct
63 Correct 393 ms 81492 KB Output is correct
64 Correct 417 ms 81624 KB Output is correct
65 Correct 482 ms 86608 KB Output is correct
66 Correct 505 ms 86688 KB Output is correct
67 Correct 467 ms 86864 KB Output is correct
68 Correct 523 ms 89688 KB Output is correct
69 Correct 527 ms 89684 KB Output is correct
70 Correct 512 ms 89168 KB Output is correct
71 Correct 510 ms 89176 KB Output is correct
72 Correct 548 ms 89208 KB Output is correct
73 Correct 384 ms 78448 KB Output is correct
74 Correct 388 ms 79444 KB Output is correct
75 Correct 389 ms 78428 KB Output is correct
76 Correct 375 ms 78504 KB Output is correct
77 Correct 378 ms 78020 KB Output is correct
78 Correct 510 ms 83136 KB Output is correct
79 Correct 409 ms 72888 KB Output is correct
80 Correct 507 ms 79272 KB Output is correct