답안 #342838

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
342838 2021-01-03T00:51:22 Z dimashii Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
30 / 100
581 ms 10312 KB
#include <bits/stdc++.h>

#define fastio ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define ll long long

using namespace std;

const int mxN = 1e6 + 45, mod = 1e9 + 7;
const ll inf = 2e18 + 43;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, m, w[mxN], p[mxN];

int main() {
	fastio;
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) cin >> w[i];
	if (m <= 5000) {
		while (m--) {
			int l, r, k;
			cin >> l >> r >> k;
			int mx = w[l];
			bool bad = 0;
			for (int i = l + 1; i <= r; ++i) {
				if (mx > w[i] && mx + w[i] > k) {
					bad = 1;
					break;
				}
				mx = max(mx, w[i]);
			}
			cout << !bad << '\n';
		}
	}else {
		// should check is subarray sorted or not
		for (int i = 2; i <= n; ++i) p[i] = p[i - 1] + (w[i] >= w[i - 1]);
		while (m--) {
			int l, r, k;
			cin >> l >> r >> k;
			if (p[r] - p[l] == r - l) cout << "1\n";
			else cout << "0\n";
		}
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
16 Correct 10 ms 364 KB Output is correct
17 Correct 10 ms 364 KB Output is correct
18 Correct 10 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 581 ms 10220 KB Output is correct
2 Correct 571 ms 10312 KB Output is correct
3 Correct 528 ms 10220 KB Output is correct
4 Correct 544 ms 10240 KB Output is correct
5 Correct 528 ms 10220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 39 ms 1516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
16 Correct 10 ms 364 KB Output is correct
17 Correct 10 ms 364 KB Output is correct
18 Correct 10 ms 364 KB Output is correct
19 Incorrect 99 ms 2412 KB Output isn't correct
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
16 Correct 10 ms 364 KB Output is correct
17 Correct 10 ms 364 KB Output is correct
18 Correct 10 ms 364 KB Output is correct
19 Correct 581 ms 10220 KB Output is correct
20 Correct 571 ms 10312 KB Output is correct
21 Correct 528 ms 10220 KB Output is correct
22 Correct 544 ms 10240 KB Output is correct
23 Correct 528 ms 10220 KB Output is correct
24 Incorrect 39 ms 1516 KB Output isn't correct
25 Halted 0 ms 0 KB -