Submission #503205

# Submission time Handle Problem Language Result Execution time Memory
503205 2022-01-07T13:38:53 Z mosiashvililuka Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
0 / 100
206 ms 40204 KB
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,ii,jj,zx,xc,tes,t,f[200009],za,seg2[800009],mx,l,r,z,K;
vector <int> seg[800009];
void bld(int q, int w, int rr){
	if(q==w) return;
	bld(q,(q+w)/2,rr*2);
	bld((q+w)/2+1,w,rr*2+1);
	int h=0,hh=0;
	for(h=0; h<seg[rr*2+1].size(); h++){
		if(seg[rr*2+1][h]>=seg[rr*2][seg[rr*2].size()-1]) break;
		seg2[rr]=seg[rr*2][seg[rr*2].size()-1]+seg[rr*2+1][h];
	}
	seg2[rr]=max(seg2[rr],seg2[rr*2]);
	seg2[rr]=max(seg2[rr],seg2[rr*2+1]);
	h=0;hh=0;
	//cout<<q<<" "<<w<<"    "<<seg[rr*2].size()<<" "<<seg[rr*2+1].size()<<"\n";
	while(h<seg[rr*2].size()||hh<seg[rr*2+1].size()){
		if(h>=seg[rr*2].size()){
			seg[rr].push_back(seg[rr*2+1][hh]);hh++;
			continue;
		}
		if(hh>=seg[rr*2+1].size()){
			seg[rr].push_back(seg[rr*2][h]);h++;
			continue;
		}
		if(seg[rr*2][h]<=seg[rr*2+1][hh]){
			seg[rr].push_back(seg[rr*2][h]);h++;
			continue;
		}else{
			seg[rr].push_back(seg[rr*2+1][hh]);hh++;
			continue;
		}
	}
}
void read(int q, int w, int rr){
	if(q>r||w<l) return;
	if(q>=l&&w<=r){
		c=lower_bound(seg[rr].begin(),seg[rr].end(),mx)-seg[rr].begin();
		if(c==0){
			mx=max(mx,seg[rr][seg[rr].size()-1]);
			return;
		}
		c--;
		z=max(z,mx+c);
		mx=max(mx,seg[rr][seg[rr].size()-1]);
		return;
	}
	read(q,(q+w)/2,rr*2);
	read((q+w)/2+1,w,rr*2+1);
}
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>tes;
	for(i=1; i<=a; i++){
		cin>>f[i];
	}
	za=1;
	while(za<a) za*=2;
	for(i=1; i<=a; i++){
		seg[i+za-1].push_back(f[i]);
	}
	for(i=a+1; i<=za; i++){
		seg[i+za-1].push_back(1000000000);
	}
	bld(1,za,1);
	//exit(0);
	for(t=1; t<=tes; t++){
		cin>>l>>r>>K;z=0;mx=0;
		read(1,za,1);
		if(z<=K){
			cout<<"1\n";
		}else{
			cout<<"0\n";
		}
	}
	return 0;
}

Compilation message

sortbooks.cpp: In function 'void bld(int, int, int)':
sortbooks.cpp:10:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |  for(h=0; h<seg[rr*2+1].size(); h++){
      |           ~^~~~~~~~~~~~~~~~~~~
sortbooks.cpp:18:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  while(h<seg[rr*2].size()||hh<seg[rr*2+1].size()){
      |        ~^~~~~~~~~~~~~~~~~
sortbooks.cpp:18:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  while(h<seg[rr*2].size()||hh<seg[rr*2+1].size()){
      |                            ~~^~~~~~~~~~~~~~~~~~~
sortbooks.cpp:19:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   if(h>=seg[rr*2].size()){
      |      ~^~~~~~~~~~~~~~~~~~
sortbooks.cpp:23:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   if(hh>=seg[rr*2+1].size()){
      |      ~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 19104 KB Output is correct
2 Correct 10 ms 19084 KB Output is correct
3 Incorrect 11 ms 19096 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 19104 KB Output is correct
2 Correct 10 ms 19084 KB Output is correct
3 Incorrect 11 ms 19096 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 42 ms 40204 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 206 ms 37820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 19104 KB Output is correct
2 Correct 10 ms 19084 KB Output is correct
3 Incorrect 11 ms 19096 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 19104 KB Output is correct
2 Correct 10 ms 19084 KB Output is correct
3 Incorrect 11 ms 19096 KB Output isn't correct
4 Halted 0 ms 0 KB -