답안 #1040428

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1040428 2024-08-01T03:55:58 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
34 / 100
398 ms 124500 KB
#include<bits/stdc++.h>
using namespace std;
long long n,q,a[1000001],t[4000004];
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 6492 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 6492 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 6488 KB Output is correct
12 Correct 3 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 3 ms 6748 KB Output is correct
15 Correct 3 ms 6748 KB Output is correct
16 Correct 3 ms 6744 KB Output is correct
17 Correct 2 ms 6748 KB Output is correct
18 Correct 3 ms 6744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 398 ms 124500 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 12880 KB Output is correct
2 Correct 56 ms 12468 KB Output is correct
3 Correct 44 ms 10856 KB Output is correct
4 Correct 45 ms 11092 KB Output is correct
5 Correct 45 ms 11092 KB Output is correct
6 Correct 36 ms 10540 KB Output is correct
7 Correct 37 ms 10588 KB Output is correct
8 Correct 40 ms 10824 KB Output is correct
9 Correct 20 ms 10516 KB Output is correct
10 Correct 42 ms 10860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 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 6488 KB Output is correct
12 Correct 3 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 3 ms 6748 KB Output is correct
15 Correct 3 ms 6748 KB Output is correct
16 Correct 3 ms 6744 KB Output is correct
17 Correct 2 ms 6748 KB Output is correct
18 Correct 3 ms 6744 KB Output is correct
19 Runtime error 78 ms 31716 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 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 6488 KB Output is correct
12 Correct 3 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 3 ms 6748 KB Output is correct
15 Correct 3 ms 6748 KB Output is correct
16 Correct 3 ms 6744 KB Output is correct
17 Correct 2 ms 6748 KB Output is correct
18 Correct 3 ms 6744 KB Output is correct
19 Runtime error 398 ms 124500 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -