Submission #498566

# Submission time Handle Problem Language Result Execution time Memory
498566 2021-12-25T14:02:55 Z The_Samurai Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++
0 / 100
3000 ms 8304 KB
#include <bits/stdc++.h>
 
using namespace std;
 
void solve() {
	int n, m, l, r, k;
	
	cin >> n >> m;
	int arr[n];
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> l >> r >> k;
		int a[n];
		for (int j = 0; j < n; j++) {
			a[i] = arr[i];
		}
		int j = l - 1;
		bool p = 1;
		while (j < r) {
			while (j + 1 < r && a[j] <= a[j + 1]) {
				j++;
			}
			j++;
			if (j == r) {
				break;
			}
			int x = j;
			while (j >= l && a[j] < a[j - 1] && a[j] + a[j - 1] <= k) {
				swap(a[j], a[j - 1]);
				j--;
			}
			if (j >= l) {
				cout << "0\n";
				p = 0;
				break;
			}
			j = x;
		}
		if (p) {
			cout << "1\n";
		}
	}
}
 
int main() {
	int t = 1;
	
//	cin >> t;
	while (t--) {
		solve();
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3040 ms 8304 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 752 ms 1436 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -