답안 #499073

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
499073 2021-12-27T07:43:54 Z Abdurahmon Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
100 / 100
943 ms 90064 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;ll a[1000006],l[1000006],r[1000006],k[1000006],t[1000006];
vector<ll>as[1000006];
void add(int k,ll x)
{
	while(k>0)
	{
		t[k]=max(t[k],x);
		k-=k&-k;	
	}	
}
ll get(int k)
{
	ll s=0;
	while(k<=n)
	{
		s=max(s,t[k]);
		k+=k&-k;
	}
	return s;
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin>>n>>m;
for(int c=1;c<=n;c++)
{
	cin>>a[c];
}
for(int c=1;c<=m;c++)
{
	cin>>l[c]>>r[c]>>k[c];as[r[c]].push_back(c);
}
vector<ll>s;
vector<bool>ans(m+1);
for(int c=1;c<=n;c++)
{
	while(s.size()&&a[s.back()]<=a[c])
	{
		s.pop_back();
	}
	ll x=(s.size()==0?0:s.back());
	add(x,a[x]+a[c]);
	for (auto i:as[c])
	{
	//	cout<<i<<" ";
		ans[i]=(get(l[i])<=k[i]);
	}
//	cout<<"\n";
	s.push_back(c);
	
	  	
}
for(int c=1;c<=m;c++)
{
	cout<<ans[c]<<"\n";
}

}
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23792 KB Output is correct
2 Correct 13 ms 23772 KB Output is correct
3 Correct 12 ms 23756 KB Output is correct
4 Correct 12 ms 23808 KB Output is correct
5 Correct 13 ms 23800 KB Output is correct
6 Correct 13 ms 23816 KB Output is correct
7 Correct 13 ms 23884 KB Output is correct
8 Correct 12 ms 23876 KB Output is correct
9 Correct 13 ms 23772 KB Output is correct
10 Correct 12 ms 23768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23792 KB Output is correct
2 Correct 13 ms 23772 KB Output is correct
3 Correct 12 ms 23756 KB Output is correct
4 Correct 12 ms 23808 KB Output is correct
5 Correct 13 ms 23800 KB Output is correct
6 Correct 13 ms 23816 KB Output is correct
7 Correct 13 ms 23884 KB Output is correct
8 Correct 12 ms 23876 KB Output is correct
9 Correct 13 ms 23772 KB Output is correct
10 Correct 12 ms 23768 KB Output is correct
11 Correct 13 ms 24012 KB Output is correct
12 Correct 13 ms 24072 KB Output is correct
13 Correct 13 ms 24140 KB Output is correct
14 Correct 18 ms 24240 KB Output is correct
15 Correct 15 ms 24268 KB Output is correct
16 Correct 15 ms 24184 KB Output is correct
17 Correct 15 ms 24140 KB Output is correct
18 Correct 17 ms 24200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 931 ms 89832 KB Output is correct
2 Correct 929 ms 90064 KB Output is correct
3 Correct 943 ms 90028 KB Output is correct
4 Correct 905 ms 90020 KB Output is correct
5 Correct 827 ms 82272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 31684 KB Output is correct
2 Correct 61 ms 31296 KB Output is correct
3 Correct 60 ms 30804 KB Output is correct
4 Correct 71 ms 30988 KB Output is correct
5 Correct 66 ms 30928 KB Output is correct
6 Correct 53 ms 30076 KB Output is correct
7 Correct 53 ms 30212 KB Output is correct
8 Correct 61 ms 30532 KB Output is correct
9 Correct 42 ms 28688 KB Output is correct
10 Correct 61 ms 30488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23792 KB Output is correct
2 Correct 13 ms 23772 KB Output is correct
3 Correct 12 ms 23756 KB Output is correct
4 Correct 12 ms 23808 KB Output is correct
5 Correct 13 ms 23800 KB Output is correct
6 Correct 13 ms 23816 KB Output is correct
7 Correct 13 ms 23884 KB Output is correct
8 Correct 12 ms 23876 KB Output is correct
9 Correct 13 ms 23772 KB Output is correct
10 Correct 12 ms 23768 KB Output is correct
11 Correct 13 ms 24012 KB Output is correct
12 Correct 13 ms 24072 KB Output is correct
13 Correct 13 ms 24140 KB Output is correct
14 Correct 18 ms 24240 KB Output is correct
15 Correct 15 ms 24268 KB Output is correct
16 Correct 15 ms 24184 KB Output is correct
17 Correct 15 ms 24140 KB Output is correct
18 Correct 17 ms 24200 KB Output is correct
19 Correct 167 ms 42140 KB Output is correct
20 Correct 151 ms 42112 KB Output is correct
21 Correct 134 ms 41236 KB Output is correct
22 Correct 144 ms 39108 KB Output is correct
23 Correct 138 ms 39092 KB Output is correct
24 Correct 120 ms 37372 KB Output is correct
25 Correct 123 ms 37328 KB Output is correct
26 Correct 131 ms 37824 KB Output is correct
27 Correct 146 ms 37952 KB Output is correct
28 Correct 148 ms 38048 KB Output is correct
29 Correct 152 ms 38552 KB Output is correct
30 Correct 145 ms 38536 KB Output is correct
31 Correct 147 ms 38536 KB Output is correct
32 Correct 144 ms 38660 KB Output is correct
33 Correct 152 ms 38528 KB Output is correct
34 Correct 116 ms 37060 KB Output is correct
35 Correct 116 ms 37108 KB Output is correct
36 Correct 110 ms 37124 KB Output is correct
37 Correct 115 ms 37092 KB Output is correct
38 Correct 117 ms 37044 KB Output is correct
39 Correct 136 ms 38760 KB Output is correct
40 Correct 110 ms 37340 KB Output is correct
41 Correct 129 ms 38272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23792 KB Output is correct
2 Correct 13 ms 23772 KB Output is correct
3 Correct 12 ms 23756 KB Output is correct
4 Correct 12 ms 23808 KB Output is correct
5 Correct 13 ms 23800 KB Output is correct
6 Correct 13 ms 23816 KB Output is correct
7 Correct 13 ms 23884 KB Output is correct
8 Correct 12 ms 23876 KB Output is correct
9 Correct 13 ms 23772 KB Output is correct
10 Correct 12 ms 23768 KB Output is correct
11 Correct 13 ms 24012 KB Output is correct
12 Correct 13 ms 24072 KB Output is correct
13 Correct 13 ms 24140 KB Output is correct
14 Correct 18 ms 24240 KB Output is correct
15 Correct 15 ms 24268 KB Output is correct
16 Correct 15 ms 24184 KB Output is correct
17 Correct 15 ms 24140 KB Output is correct
18 Correct 17 ms 24200 KB Output is correct
19 Correct 931 ms 89832 KB Output is correct
20 Correct 929 ms 90064 KB Output is correct
21 Correct 943 ms 90028 KB Output is correct
22 Correct 905 ms 90020 KB Output is correct
23 Correct 827 ms 82272 KB Output is correct
24 Correct 65 ms 31684 KB Output is correct
25 Correct 61 ms 31296 KB Output is correct
26 Correct 60 ms 30804 KB Output is correct
27 Correct 71 ms 30988 KB Output is correct
28 Correct 66 ms 30928 KB Output is correct
29 Correct 53 ms 30076 KB Output is correct
30 Correct 53 ms 30212 KB Output is correct
31 Correct 61 ms 30532 KB Output is correct
32 Correct 42 ms 28688 KB Output is correct
33 Correct 61 ms 30488 KB Output is correct
34 Correct 167 ms 42140 KB Output is correct
35 Correct 151 ms 42112 KB Output is correct
36 Correct 134 ms 41236 KB Output is correct
37 Correct 144 ms 39108 KB Output is correct
38 Correct 138 ms 39092 KB Output is correct
39 Correct 120 ms 37372 KB Output is correct
40 Correct 123 ms 37328 KB Output is correct
41 Correct 131 ms 37824 KB Output is correct
42 Correct 146 ms 37952 KB Output is correct
43 Correct 148 ms 38048 KB Output is correct
44 Correct 152 ms 38552 KB Output is correct
45 Correct 145 ms 38536 KB Output is correct
46 Correct 147 ms 38536 KB Output is correct
47 Correct 144 ms 38660 KB Output is correct
48 Correct 152 ms 38528 KB Output is correct
49 Correct 116 ms 37060 KB Output is correct
50 Correct 116 ms 37108 KB Output is correct
51 Correct 110 ms 37124 KB Output is correct
52 Correct 115 ms 37092 KB Output is correct
53 Correct 117 ms 37044 KB Output is correct
54 Correct 136 ms 38760 KB Output is correct
55 Correct 110 ms 37340 KB Output is correct
56 Correct 129 ms 38272 KB Output is correct
57 Correct 900 ms 89476 KB Output is correct
58 Correct 886 ms 89320 KB Output is correct
59 Correct 813 ms 86640 KB Output is correct
60 Correct 817 ms 86660 KB Output is correct
61 Correct 817 ms 86516 KB Output is correct
62 Correct 816 ms 86476 KB Output is correct
63 Correct 577 ms 74660 KB Output is correct
64 Correct 573 ms 74700 KB Output is correct
65 Correct 795 ms 78432 KB Output is correct
66 Correct 773 ms 78456 KB Output is correct
67 Correct 754 ms 78608 KB Output is correct
68 Correct 858 ms 81564 KB Output is correct
69 Correct 818 ms 81528 KB Output is correct
70 Correct 814 ms 80912 KB Output is correct
71 Correct 829 ms 81020 KB Output is correct
72 Correct 820 ms 81012 KB Output is correct
73 Correct 566 ms 73032 KB Output is correct
74 Correct 562 ms 72772 KB Output is correct
75 Correct 529 ms 72844 KB Output is correct
76 Correct 548 ms 73008 KB Output is correct
77 Correct 551 ms 72652 KB Output is correct
78 Correct 738 ms 81284 KB Output is correct
79 Correct 573 ms 72004 KB Output is correct
80 Correct 720 ms 78632 KB Output is correct