Submission #1071436

# Submission time Handle Problem Language Result Execution time Memory
1071436 2024-08-23T07:21:52 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
0 / 100
3000 ms 21616 KB
#include <bits/stdc++.h>
#define int long long
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout)
const int N=1e6+1;
const int inf=1e18;
const int mod=1e9+7;
using namespace std;
int n;
struct edge{
	int mn,mx,ps;
};
vector<int>v;
vector<int>v1;
signed main(){
	boost;
	int n,m;
	cin>>n>>m;
	v.push_back(0);
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		v.push_back(x);
	}
	while(m--){
		int l,r,k;
		cin>>l>>r>>k;
		int mx=0;
		int mn=inf;
		int ok=0;
		for(int i=l;i<=r;i++){
			v1.push_back(v[i]);
		}
		sort(v1.begin(),v1.end());
		int p=l;
		for(int i=0;i<v1.size();i++){
			if(v1[i]!=v[p]){
				mx=max(mx,v1[i]);
			}
			p++;
			mn=min(mn,v1[i]);
		}
		if(mx+mn<=k||mx==0){
			cout<<1<<"\n";
		}else{
			cout<<0<<"\n";
		}
		v1.clear();
	}
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:36:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   for(int i=0;i<v1.size();i++){
      |               ~^~~~~~~~~~
sortbooks.cpp:30:7: warning: unused variable 'ok' [-Wunused-variable]
   30 |   int ok=0;
      |       ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3047 ms 21616 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3064 ms 2776 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -