Submission #493180

# Submission time Handle Problem Language Result Execution time Memory
493180 2021-12-10T10:19:55 Z irmuun Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
0 / 100
3000 ms 6724 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n,m,w[200001],h[200001],l,r,k,ans,i,j,b,c,mx=0;
	cin>>n>>m;
	for(i=1;i<=n;i++){
		cin>>w[i];
		mx=max(mx,w[i]);
		h[i]=w[i];
	}
	for(i=1;i<=m;i++){
		cin>>l>>r>>k;
		if(k<w[i]){
			c=1;
			for(j=l+1;j<=r;j++){
				if(w[j+1]<w[j]){
					c=0;
					break;
				}
			}
			cout<<c<<endl;
			continue;
		}
		c=0;
		while(c==0){
			c=1;
			for(j=l;j<r;j++){
				if(w[j]+w[j+1]<=k&&w[j]>w[j+1]){
					c=0;
					swap(w[j],w[j+1]);
				}
			}
		}
		c=1;
		for(j=l;j<r;j++){
			if(w[j]>w[j+1]){
				c=0;
				break;
			}
		}
		cout<<c<<endl;
		for(j=l;j<=r;j++){
			w[j]=h[j];
		}
	}
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:5:35: warning: unused variable 'ans' [-Wunused-variable]
    5 |  ll n,m,w[200001],h[200001],l,r,k,ans,i,j,b,c,mx=0;
      |                                   ^~~
sortbooks.cpp:5:43: warning: unused variable 'b' [-Wunused-variable]
    5 |  ll n,m,w[200001],h[200001],l,r,k,ans,i,j,b,c,mx=0;
      |                                           ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3404 KB Output is correct
2 Correct 1 ms 3404 KB Output is correct
3 Correct 5 ms 3404 KB Output is correct
4 Incorrect 2 ms 3404 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3404 KB Output is correct
2 Correct 1 ms 3404 KB Output is correct
3 Correct 5 ms 3404 KB Output is correct
4 Incorrect 2 ms 3404 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 83 ms 6724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3053 ms 3404 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3404 KB Output is correct
2 Correct 1 ms 3404 KB Output is correct
3 Correct 5 ms 3404 KB Output is correct
4 Incorrect 2 ms 3404 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3404 KB Output is correct
2 Correct 1 ms 3404 KB Output is correct
3 Correct 5 ms 3404 KB Output is correct
4 Incorrect 2 ms 3404 KB Output isn't correct
5 Halted 0 ms 0 KB -