답안 #146922

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
146922 2019-08-26T15:39:44 Z Pajaraja Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
100 / 100
2638 ms 171212 KB
#include <bits/stdc++.h>
#define MAXN 1000007
using namespace std;
int seg[4*MAXN],a[MAXN],ans[MAXN];
vector<int> ul[MAXN],uk[MAXN],ind[MAXN];
void upd(int l,int r,int x,int v,int ind)
{
	if(l==r) {seg[ind]=v; return;}
	int s=(l+r)/2;
	if(x<=s) upd(l,s,x,v,2*ind);
	else upd(s+1,r,x,v,2*ind+1);
	seg[ind]=max(seg[2*ind],seg[2*ind+1]);
}
int nmax(int l,int r,int lt,int rt,int ind)
{
	if(l>=lt && r<=rt) return seg[ind];
	if(l>rt || r<lt) return 0;
	int s=(l+r)/2;
	return max(nmax(l,s,lt,rt,2*ind),nmax(s+1,r,lt,rt,2*ind+1));
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	a[0]=1000000007;
	for(int i=0;i<m;i++)
	{
		int t1,t2,t3;
		scanf("%d%d%d",&t1,&t2,&t3);
		ul[t2].push_back(t1); uk[t2].push_back(t3); ind[t2].push_back(i);
	}
	stack<int> st; st.push(0);
	for(int i=1;i<=n;i++)
	{
		while(a[st.top()]<=a[i]) st.pop();
		upd(0,n,st.top(),a[i]+a[st.top()],1);
		st.push(i);
		for(int j=0;j<ul[i].size();j++) ans[ind[i][j]]=(nmax(0,n,ul[i][j],i,1)>uk[i][j]?0:1);
	}
	for(int i=0;i<m;i++) printf("%d\n",ans[i]);
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:39:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<ul[i].size();j++) ans[ind[i][j]]=(nmax(0,n,ul[i][j],i,1)>uk[i][j]?0:1);
               ~^~~~~~~~~~~~~
sortbooks.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~
sortbooks.cpp:25:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
                        ~~~~~^~~~~~~~~~~~
sortbooks.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d",&t1,&t2,&t3);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 70904 KB Output is correct
2 Correct 67 ms 70776 KB Output is correct
3 Correct 67 ms 70776 KB Output is correct
4 Correct 68 ms 70904 KB Output is correct
5 Correct 67 ms 70776 KB Output is correct
6 Correct 68 ms 70904 KB Output is correct
7 Correct 68 ms 70872 KB Output is correct
8 Correct 68 ms 70776 KB Output is correct
9 Correct 68 ms 70776 KB Output is correct
10 Correct 68 ms 70776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 70904 KB Output is correct
2 Correct 67 ms 70776 KB Output is correct
3 Correct 67 ms 70776 KB Output is correct
4 Correct 68 ms 70904 KB Output is correct
5 Correct 67 ms 70776 KB Output is correct
6 Correct 68 ms 70904 KB Output is correct
7 Correct 68 ms 70872 KB Output is correct
8 Correct 68 ms 70776 KB Output is correct
9 Correct 68 ms 70776 KB Output is correct
10 Correct 68 ms 70776 KB Output is correct
11 Correct 75 ms 71020 KB Output is correct
12 Correct 73 ms 71004 KB Output is correct
13 Correct 75 ms 71160 KB Output is correct
14 Correct 75 ms 71132 KB Output is correct
15 Correct 75 ms 71312 KB Output is correct
16 Correct 75 ms 71160 KB Output is correct
17 Correct 74 ms 71160 KB Output is correct
18 Correct 73 ms 71160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2627 ms 142844 KB Output is correct
2 Correct 2634 ms 142756 KB Output is correct
3 Correct 2630 ms 142760 KB Output is correct
4 Correct 2614 ms 142868 KB Output is correct
5 Correct 2481 ms 134652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 254 ms 77788 KB Output is correct
2 Correct 212 ms 75396 KB Output is correct
3 Correct 230 ms 76024 KB Output is correct
4 Correct 239 ms 76448 KB Output is correct
5 Correct 244 ms 76648 KB Output is correct
6 Correct 167 ms 73672 KB Output is correct
7 Correct 175 ms 73592 KB Output is correct
8 Correct 217 ms 76508 KB Output is correct
9 Correct 124 ms 72816 KB Output is correct
10 Correct 215 ms 76400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 70904 KB Output is correct
2 Correct 67 ms 70776 KB Output is correct
3 Correct 67 ms 70776 KB Output is correct
4 Correct 68 ms 70904 KB Output is correct
5 Correct 67 ms 70776 KB Output is correct
6 Correct 68 ms 70904 KB Output is correct
7 Correct 68 ms 70872 KB Output is correct
8 Correct 68 ms 70776 KB Output is correct
9 Correct 68 ms 70776 KB Output is correct
10 Correct 68 ms 70776 KB Output is correct
11 Correct 75 ms 71020 KB Output is correct
12 Correct 73 ms 71004 KB Output is correct
13 Correct 75 ms 71160 KB Output is correct
14 Correct 75 ms 71132 KB Output is correct
15 Correct 75 ms 71312 KB Output is correct
16 Correct 75 ms 71160 KB Output is correct
17 Correct 74 ms 71160 KB Output is correct
18 Correct 73 ms 71160 KB Output is correct
19 Correct 503 ms 84648 KB Output is correct
20 Correct 501 ms 84632 KB Output is correct
21 Correct 386 ms 79524 KB Output is correct
22 Correct 381 ms 79480 KB Output is correct
23 Correct 402 ms 79392 KB Output is correct
24 Correct 343 ms 77048 KB Output is correct
25 Correct 349 ms 83192 KB Output is correct
26 Correct 432 ms 85532 KB Output is correct
27 Correct 422 ms 85640 KB Output is correct
28 Correct 437 ms 86392 KB Output is correct
29 Correct 494 ms 89088 KB Output is correct
30 Correct 478 ms 89336 KB Output is correct
31 Correct 474 ms 89008 KB Output is correct
32 Correct 495 ms 88864 KB Output is correct
33 Correct 478 ms 88952 KB Output is correct
34 Correct 299 ms 82300 KB Output is correct
35 Correct 303 ms 82488 KB Output is correct
36 Correct 298 ms 82372 KB Output is correct
37 Correct 298 ms 82308 KB Output is correct
38 Correct 304 ms 82424 KB Output is correct
39 Correct 418 ms 87404 KB Output is correct
40 Correct 335 ms 84836 KB Output is correct
41 Correct 396 ms 86588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 70904 KB Output is correct
2 Correct 67 ms 70776 KB Output is correct
3 Correct 67 ms 70776 KB Output is correct
4 Correct 68 ms 70904 KB Output is correct
5 Correct 67 ms 70776 KB Output is correct
6 Correct 68 ms 70904 KB Output is correct
7 Correct 68 ms 70872 KB Output is correct
8 Correct 68 ms 70776 KB Output is correct
9 Correct 68 ms 70776 KB Output is correct
10 Correct 68 ms 70776 KB Output is correct
11 Correct 75 ms 71020 KB Output is correct
12 Correct 73 ms 71004 KB Output is correct
13 Correct 75 ms 71160 KB Output is correct
14 Correct 75 ms 71132 KB Output is correct
15 Correct 75 ms 71312 KB Output is correct
16 Correct 75 ms 71160 KB Output is correct
17 Correct 74 ms 71160 KB Output is correct
18 Correct 73 ms 71160 KB Output is correct
19 Correct 2627 ms 142844 KB Output is correct
20 Correct 2634 ms 142756 KB Output is correct
21 Correct 2630 ms 142760 KB Output is correct
22 Correct 2614 ms 142868 KB Output is correct
23 Correct 2481 ms 134652 KB Output is correct
24 Correct 254 ms 77788 KB Output is correct
25 Correct 212 ms 75396 KB Output is correct
26 Correct 230 ms 76024 KB Output is correct
27 Correct 239 ms 76448 KB Output is correct
28 Correct 244 ms 76648 KB Output is correct
29 Correct 167 ms 73672 KB Output is correct
30 Correct 175 ms 73592 KB Output is correct
31 Correct 217 ms 76508 KB Output is correct
32 Correct 124 ms 72816 KB Output is correct
33 Correct 215 ms 76400 KB Output is correct
34 Correct 503 ms 84648 KB Output is correct
35 Correct 501 ms 84632 KB Output is correct
36 Correct 386 ms 79524 KB Output is correct
37 Correct 381 ms 79480 KB Output is correct
38 Correct 402 ms 79392 KB Output is correct
39 Correct 343 ms 77048 KB Output is correct
40 Correct 349 ms 83192 KB Output is correct
41 Correct 432 ms 85532 KB Output is correct
42 Correct 422 ms 85640 KB Output is correct
43 Correct 437 ms 86392 KB Output is correct
44 Correct 494 ms 89088 KB Output is correct
45 Correct 478 ms 89336 KB Output is correct
46 Correct 474 ms 89008 KB Output is correct
47 Correct 495 ms 88864 KB Output is correct
48 Correct 478 ms 88952 KB Output is correct
49 Correct 299 ms 82300 KB Output is correct
50 Correct 303 ms 82488 KB Output is correct
51 Correct 298 ms 82372 KB Output is correct
52 Correct 298 ms 82308 KB Output is correct
53 Correct 304 ms 82424 KB Output is correct
54 Correct 418 ms 87404 KB Output is correct
55 Correct 335 ms 84836 KB Output is correct
56 Correct 396 ms 86588 KB Output is correct
57 Correct 2618 ms 171212 KB Output is correct
58 Correct 2638 ms 171128 KB Output is correct
59 Correct 2464 ms 158840 KB Output is correct
60 Correct 2486 ms 158712 KB Output is correct
61 Correct 2460 ms 158588 KB Output is correct
62 Correct 2453 ms 158796 KB Output is correct
63 Correct 1565 ms 130296 KB Output is correct
64 Correct 1568 ms 130388 KB Output is correct
65 Correct 2295 ms 149112 KB Output is correct
66 Correct 2272 ms 148984 KB Output is correct
67 Correct 2296 ms 149812 KB Output is correct
68 Correct 2445 ms 163032 KB Output is correct
69 Correct 2456 ms 163084 KB Output is correct
70 Correct 2421 ms 160672 KB Output is correct
71 Correct 2429 ms 160760 KB Output is correct
72 Correct 2476 ms 160840 KB Output is correct
73 Correct 1345 ms 127412 KB Output is correct
74 Correct 1336 ms 128460 KB Output is correct
75 Correct 1347 ms 127280 KB Output is correct
76 Correct 1321 ms 127480 KB Output is correct
77 Correct 1326 ms 127264 KB Output is correct
78 Correct 2087 ms 154284 KB Output is correct
79 Correct 1528 ms 137816 KB Output is correct
80 Correct 1918 ms 150428 KB Output is correct