Submission #493189

# Submission time Handle Problem Language Result Execution time Memory
493189 2021-12-10T10:31:02 Z irmuun Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
8 / 100
3000 ms 8572 KB
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define PI 3.14159265359
int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(false);
	ll n,m,w[200001],h[200001],l,r,k,ans,i,j,b,c,mn=1e9,a;
	vector<ll>v;
	cin>>n>>m;
	for(i=1;i<=n;i++){
		cin>>w[i];
		if(i>1){
			if(w[i]<w[i-1]){
				v.pb(i);
			}
		}
		mn=min(mn,w[i]);
		h[i]=w[i];
	}
	for(i=1;i<=m;i++){
		cin>>l>>r>>k;
		if(k<mn&&v.size()>0){
			a=0;
			b=v.size()-1;
			while(a<b){
				c=(a+b)/2;
				if(w[c]<=l){
					a=c+1;
				}
				else{
					b=c;
				}
			}
			if(l<v[c]&&v[c]<=r){
				cout<<1<<endl;
			}
			else{
				cout<<0<<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:12:35: warning: unused variable 'ans' [-Wunused-variable]
   12 |  ll n,m,w[200001],h[200001],l,r,k,ans,i,j,b,c,mn=1e9,a;
      |                                   ^~~
sortbooks.cpp:39:12: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
   39 |    if(l<v[c]&&v[c]<=r){
      |            ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3404 KB Output is correct
2 Correct 2 ms 3404 KB Output is correct
3 Correct 4 ms 3404 KB Output is correct
4 Correct 2 ms 3404 KB Output is correct
5 Correct 2 ms 3404 KB Output is correct
6 Correct 33 ms 3404 KB Output is correct
7 Correct 31 ms 3404 KB Output is correct
8 Correct 17 ms 3404 KB Output is correct
9 Correct 17 ms 3404 KB Output is correct
10 Correct 18 ms 3404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3404 KB Output is correct
2 Correct 2 ms 3404 KB Output is correct
3 Correct 4 ms 3404 KB Output is correct
4 Correct 2 ms 3404 KB Output is correct
5 Correct 2 ms 3404 KB Output is correct
6 Correct 33 ms 3404 KB Output is correct
7 Correct 31 ms 3404 KB Output is correct
8 Correct 17 ms 3404 KB Output is correct
9 Correct 17 ms 3404 KB Output is correct
10 Correct 18 ms 3404 KB Output is correct
11 Correct 1582 ms 3444 KB Output is correct
12 Execution timed out 3078 ms 3404 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 27 ms 8572 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3073 ms 4048 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 2 ms 3404 KB Output is correct
3 Correct 4 ms 3404 KB Output is correct
4 Correct 2 ms 3404 KB Output is correct
5 Correct 2 ms 3404 KB Output is correct
6 Correct 33 ms 3404 KB Output is correct
7 Correct 31 ms 3404 KB Output is correct
8 Correct 17 ms 3404 KB Output is correct
9 Correct 17 ms 3404 KB Output is correct
10 Correct 18 ms 3404 KB Output is correct
11 Correct 1582 ms 3444 KB Output is correct
12 Execution timed out 3078 ms 3404 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3404 KB Output is correct
2 Correct 2 ms 3404 KB Output is correct
3 Correct 4 ms 3404 KB Output is correct
4 Correct 2 ms 3404 KB Output is correct
5 Correct 2 ms 3404 KB Output is correct
6 Correct 33 ms 3404 KB Output is correct
7 Correct 31 ms 3404 KB Output is correct
8 Correct 17 ms 3404 KB Output is correct
9 Correct 17 ms 3404 KB Output is correct
10 Correct 18 ms 3404 KB Output is correct
11 Correct 1582 ms 3444 KB Output is correct
12 Execution timed out 3078 ms 3404 KB Time limit exceeded
13 Halted 0 ms 0 KB -