Submission #889870

# Submission time Handle Problem Language Result Execution time Memory
889870 2023-12-20T08:44:31 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
0 / 100
3000 ms 12892 KB
#include <bits/stdc++.h>
#define ll long long
#define fort(x , y) for(int y = 1 ; y <= x ; y++)
#define pb push_back
#define pf push_front
#define ppb pop_back
#define int long long
#define F first
#define S second
using namespace std;
const int N = 2e5 + 5;
const int NN = 1e9 + 7;
int n,m,w[N],l,r,k,p[N],b[N],swpd[N];
signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin >> n >> m;
	for(int i = 1 ; i <= n ; i++){
		cin >> w[i];
		p[i] = p[i - 1] + w[i];
		b[i] = w[i];
	}
	sort(b + 1 , b + n + 1);
	for(int j = 1 ; j <= m ; j++){
		cin >> l >> r >> k;
		if(l == r){
			if(w[l] <= k){
				cout << 1 << '\n';
			}
			else{
				cout << 0 << '\n';
			}
			continue;
		}
		int ans = 0;
		for(int i = l ; i <= r ; i++){
			for(int u = l ; u <= r ; u++){
				if(u == i){
					continue;
				}
				if(w[u] + w[i] <= k){
					ans++;
				}
			}
		}
		if(ans / 2 > (r - l + 1) / 2){
			cout << 1 << '\n';
		}
		else{
			cout << 0 << '\n';
		}
	}

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Incorrect 2 ms 2392 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Incorrect 2 ms 2392 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 25 ms 12892 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3043 ms 4188 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Incorrect 2 ms 2392 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Incorrect 2 ms 2392 KB Output isn't correct
4 Halted 0 ms 0 KB -