답안 #519740

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
519740 2022-01-27T08:06:38 Z shmad Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
30 / 100
474 ms 31596 KB
#pragma GCC optimize("O3", "unroll-loops") // "Ofast"
#pragma GCC target("avx2", "bmi", "bmi2", "lzcnt", "popcnt") 

#include <bits/stdc++.h>

#define int long long
#define vt vector
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define ff first
#define ss second
#define dbg(x) cerr << #x << " = " << x << '\n'

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vvi = vt< vt<int> >;

const int N = 1e6 + 5, mod = 1e9 + 7, inf = 1e18 + 7, B = 500, LIM = (1ll << 60);
const double eps = 1e-6;

int n, m;
vt<int> w(N), ans(N), p(N);

void solve_1_2 () {
	for (int q = 1; q <= m; q++) {
		int l, r, k;
		cin >> l >> r >> k;
		int res = -inf, mx = -inf;
		for (int i = l; i <= r; i++) {
			if (mx > w[i]) res = max(res, mx + w[i]);
			mx = max(mx, w[i]);
		}
		ans[q] = (res <= k);
	}
	for (int i = 1; i <= m; i++) cout << ans[i] << '\n';
}

void solve_3 () {
	for (int i = 2; i <= n; i++) p[i] = p[i - 1] + (w[i] >= w[i - 1]);
	for (int q = 1; q <= m; q++) {
		int l, r, k;
		cin >> l >> r >> k;
		ans[q] = (p[r] - p[l] + 1 == r - l + 1);
	}
	for (int i = 1; i <= m; i++) cout << ans[i] << '\n';
}

void solve () {
	cin >> n >> m;
	int mn = inf;
	for (int i = 1; i <= n; i++) cin >> w[i], mn = min(mn, w[i]);
	bool sub_1_2 = (n <= 5000 && m <= 5000);
	if (sub_1_2) {
		solve_1_2();
		return;
	}
	solve_3();
	cout << '\n';
}

bool testcases = 0;
                  
signed main() {
#ifdef ONLINE_JUDGE
	freopen(".in", "r", stdin);
	freopen(".out", "w", stdout);
#endif
    cin.tie(0) -> sync_with_stdio(0);
    int test = 1;
    if (testcases) cin >> test;
    for (int cs = 1; cs <= test; cs++) {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 23756 KB Output is correct
2 Correct 10 ms 23756 KB Output is correct
3 Correct 14 ms 23756 KB Output is correct
4 Correct 10 ms 23756 KB Output is correct
5 Correct 10 ms 23796 KB Output is correct
6 Correct 10 ms 23756 KB Output is correct
7 Correct 10 ms 23756 KB Output is correct
8 Correct 12 ms 23760 KB Output is correct
9 Correct 10 ms 23756 KB Output is correct
10 Correct 10 ms 23700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 23756 KB Output is correct
2 Correct 10 ms 23756 KB Output is correct
3 Correct 14 ms 23756 KB Output is correct
4 Correct 10 ms 23756 KB Output is correct
5 Correct 10 ms 23796 KB Output is correct
6 Correct 10 ms 23756 KB Output is correct
7 Correct 10 ms 23756 KB Output is correct
8 Correct 12 ms 23760 KB Output is correct
9 Correct 10 ms 23756 KB Output is correct
10 Correct 10 ms 23700 KB Output is correct
11 Correct 12 ms 23756 KB Output is correct
12 Correct 16 ms 23820 KB Output is correct
13 Correct 15 ms 23744 KB Output is correct
14 Correct 25 ms 23820 KB Output is correct
15 Correct 21 ms 23756 KB Output is correct
16 Correct 29 ms 23756 KB Output is correct
17 Correct 25 ms 23768 KB Output is correct
18 Correct 30 ms 23792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 459 ms 25720 KB Output is correct
2 Correct 463 ms 31596 KB Output is correct
3 Correct 459 ms 31404 KB Output is correct
4 Correct 464 ms 31488 KB Output is correct
5 Correct 474 ms 31468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 41 ms 24004 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 23756 KB Output is correct
2 Correct 10 ms 23756 KB Output is correct
3 Correct 14 ms 23756 KB Output is correct
4 Correct 10 ms 23756 KB Output is correct
5 Correct 10 ms 23796 KB Output is correct
6 Correct 10 ms 23756 KB Output is correct
7 Correct 10 ms 23756 KB Output is correct
8 Correct 12 ms 23760 KB Output is correct
9 Correct 10 ms 23756 KB Output is correct
10 Correct 10 ms 23700 KB Output is correct
11 Correct 12 ms 23756 KB Output is correct
12 Correct 16 ms 23820 KB Output is correct
13 Correct 15 ms 23744 KB Output is correct
14 Correct 25 ms 23820 KB Output is correct
15 Correct 21 ms 23756 KB Output is correct
16 Correct 29 ms 23756 KB Output is correct
17 Correct 25 ms 23768 KB Output is correct
18 Correct 30 ms 23792 KB Output is correct
19 Incorrect 90 ms 24180 KB Output isn't correct
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 23756 KB Output is correct
2 Correct 10 ms 23756 KB Output is correct
3 Correct 14 ms 23756 KB Output is correct
4 Correct 10 ms 23756 KB Output is correct
5 Correct 10 ms 23796 KB Output is correct
6 Correct 10 ms 23756 KB Output is correct
7 Correct 10 ms 23756 KB Output is correct
8 Correct 12 ms 23760 KB Output is correct
9 Correct 10 ms 23756 KB Output is correct
10 Correct 10 ms 23700 KB Output is correct
11 Correct 12 ms 23756 KB Output is correct
12 Correct 16 ms 23820 KB Output is correct
13 Correct 15 ms 23744 KB Output is correct
14 Correct 25 ms 23820 KB Output is correct
15 Correct 21 ms 23756 KB Output is correct
16 Correct 29 ms 23756 KB Output is correct
17 Correct 25 ms 23768 KB Output is correct
18 Correct 30 ms 23792 KB Output is correct
19 Correct 459 ms 25720 KB Output is correct
20 Correct 463 ms 31596 KB Output is correct
21 Correct 459 ms 31404 KB Output is correct
22 Correct 464 ms 31488 KB Output is correct
23 Correct 474 ms 31468 KB Output is correct
24 Incorrect 41 ms 24004 KB Output isn't correct
25 Halted 0 ms 0 KB -