Submission #1071612

# Submission time Handle Problem Language Result Execution time Memory
1071612 2024-08-23T09:20:30 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++
0 / 100
2556 ms 262144 KB
// Balgabaev Mansur
#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define pb push_back
#define int long long


using namespace std;

const int N=1e5+7;
const int MOD=1e9+7;
const int INF=1e18;

int binpow (int a, int n) {
	if (n == 0)
		return 1;
	if (n % 2 == 1)
		return binpow (a, n-1) * a;
	else {
		int b = binpow (a, n/2);
		return b * b;
	}
}

int a[N],nxt[5005][5005];

void solve(){
	int n,m;
	cin >> n >> m;
	for(int i = 1 ; i <= n ; i++){
		cin >> a[i];
	}
	for(int i = 1 ; i < n ; i++){
		nxt[i][i]=a[i];
		for(int j = i+1 ; j <= n ; j++){
			nxt[i][j]=min(nxt[i][j-1],a[j]);
		}
	}
	while(m--){
		int l,r,k;
		bool ok=false;
		cin >> l >> r >> k;
		for(int i = l ; i <= r ; i++){
			if(a[i]+nxt[i][r] > k){
				cout << 0 << '\n';
				ok=true;
				break;
			}
		}
		if(!ok){
			cout << 1 << '\n';
		}
	}
}	
 
signed main() {
   // freopen("closing.in", "r", stdin);
   // freopen("closing.out", "w", stdout);
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int test = 1,cntx=1;
    //cin >> test;
    while (test--) {
	//cout << "Case " << 	cntx << ':' << '\n';
        solve();
        cntx++;
	}		
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 6492 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 6492 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 2140 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2556 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 6492 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 6492 KB Output isn't correct
4 Halted 0 ms 0 KB -