답안 #1040427

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1040427 2024-08-01T03:55:01 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
64 / 100
120 ms 20824 KB
#include<bits/stdc++.h>
using namespace std;
long long n,q,a[200001],t[800004],lz[8000004];
long long k;
bool kt;
void build(long long id ,long long l,long long r)
{
	if(l==r)
	{
		t[id]=a[l];
		return;
	}
	long long mid=(l+r)/2;
	build(id*2,l,mid);
	build(id*2+1,mid+1,r);
	t[id]=max(t[id*2],t[id*2+1]);
}
void update(long long id,long long l,long long r,long long pos,long long w)
{
	if(l>pos||pos>r) return ;
	if(l==r)
	{
		t[id]=max(t[id],w);
		return;
	}
	long long mid=(l+r)/2;
	update(id*2,l,mid,pos,w);
	update(id*2+1,mid+1,r,pos,w);
	t[id]=max(t[id*2],t[id*2+1]);
}
long long get_max(long long id,long long l,long long r,long long u,long long v)
{
	if(l>v||r<u) return -1000000009;
	if(u<=l&&r<=v)
	{
		return t[id];
	}
	long long mid=(l+r)/2;
	return max(get_max(id*2,l,mid,u,v),get_max(id*2+1,mid+1,r,u,v));
}
vector<pair<int,pair<int,int>>> eve[100005]; 
long long ans[1000005];
int main() 
{
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>q;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=q;i++)
	{
		long long l,r,k;
		cin>>l>>r>>k;
		eve[r].push_back({i,{l,k}});
	}
	stack<int> st;
	for(int i=1;i<=n;i++)
	{
		while(!st.empty()&&a[st.top()]<=a[i]) st.pop();
		if(st.size()) update(1,1,n,st.top(),a[st.top()]+a[i]);
		st.push(i);
		for(auto x:eve[i])
		{
			long long id=x.first,l=x.second.first,k=x.second.second;
			if(get_max(1,1,n,l,i)<=k) ans[id]=1;
			else ans[id]=0;
		}
	}
	for(int i=1;i<=q;i++)
	{
		cout<<ans[i]<<"\n";
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 2 ms 6748 KB Output is correct
12 Correct 2 ms 6748 KB Output is correct
13 Correct 2 ms 6748 KB Output is correct
14 Correct 3 ms 6748 KB Output is correct
15 Correct 4 ms 6748 KB Output is correct
16 Correct 3 ms 6744 KB Output is correct
17 Correct 2 ms 6744 KB Output is correct
18 Correct 2 ms 6788 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 16 ms 13912 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 13088 KB Output is correct
2 Correct 51 ms 12880 KB Output is correct
3 Correct 44 ms 10844 KB Output is correct
4 Correct 45 ms 11088 KB Output is correct
5 Correct 45 ms 11092 KB Output is correct
6 Correct 36 ms 10580 KB Output is correct
7 Correct 36 ms 10588 KB Output is correct
8 Correct 47 ms 10828 KB Output is correct
9 Correct 21 ms 10516 KB Output is correct
10 Correct 39 ms 10856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 2 ms 6748 KB Output is correct
12 Correct 2 ms 6748 KB Output is correct
13 Correct 2 ms 6748 KB Output is correct
14 Correct 3 ms 6748 KB Output is correct
15 Correct 4 ms 6748 KB Output is correct
16 Correct 3 ms 6744 KB Output is correct
17 Correct 2 ms 6744 KB Output is correct
18 Correct 2 ms 6788 KB Output is correct
19 Correct 119 ms 20820 KB Output is correct
20 Correct 120 ms 20824 KB Output is correct
21 Correct 110 ms 18772 KB Output is correct
22 Correct 108 ms 18768 KB Output is correct
23 Correct 113 ms 18548 KB Output is correct
24 Correct 87 ms 13396 KB Output is correct
25 Correct 92 ms 13396 KB Output is correct
26 Correct 95 ms 14932 KB Output is correct
27 Correct 100 ms 14932 KB Output is correct
28 Correct 95 ms 15592 KB Output is correct
29 Correct 109 ms 15952 KB Output is correct
30 Correct 100 ms 15952 KB Output is correct
31 Correct 100 ms 15788 KB Output is correct
32 Correct 98 ms 15952 KB Output is correct
33 Correct 101 ms 15952 KB Output is correct
34 Correct 90 ms 14928 KB Output is correct
35 Correct 94 ms 14928 KB Output is correct
36 Correct 85 ms 14932 KB Output is correct
37 Correct 81 ms 14932 KB Output is correct
38 Correct 79 ms 14928 KB Output is correct
39 Correct 88 ms 16940 KB Output is correct
40 Correct 67 ms 13060 KB Output is correct
41 Correct 87 ms 15576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 2 ms 6748 KB Output is correct
12 Correct 2 ms 6748 KB Output is correct
13 Correct 2 ms 6748 KB Output is correct
14 Correct 3 ms 6748 KB Output is correct
15 Correct 4 ms 6748 KB Output is correct
16 Correct 3 ms 6744 KB Output is correct
17 Correct 2 ms 6744 KB Output is correct
18 Correct 2 ms 6788 KB Output is correct
19 Runtime error 16 ms 13912 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -