답안 #498569

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
498569 2021-12-25T14:12:31 Z The_Samurai Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++
0 / 100
3000 ms 8280 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[j] = arr[j];
		}
		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) {
				a[j] += a[j - 1];
				a[j - 1] = a[j] - a[j - 1];
				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();
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3077 ms 8280 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1839 ms 1280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -