Submission #519709

# Submission time Handle Problem Language Result Execution time Memory
519709 2022-01-27T05:27:08 Z shmad Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
17 / 100
3000 ms 20416 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;

void solve () {
	int n, m;
	cin >> n >> m;
	vt<int> w(n + 1), ans(m + 1);
	for (int i = 1; i <= n; i++) cin >> w[i];
	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';
	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();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 4 ms 300 KB Output is correct
12 Correct 6 ms 448 KB Output is correct
13 Correct 7 ms 460 KB Output is correct
14 Correct 11 ms 540 KB Output is correct
15 Correct 11 ms 536 KB Output is correct
16 Correct 18 ms 492 KB Output is correct
17 Correct 16 ms 480 KB Output is correct
18 Correct 21 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3053 ms 20416 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2532 ms 4040 KB Output is correct
2 Execution timed out 3059 ms 2884 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 4 ms 300 KB Output is correct
12 Correct 6 ms 448 KB Output is correct
13 Correct 7 ms 460 KB Output is correct
14 Correct 11 ms 540 KB Output is correct
15 Correct 11 ms 536 KB Output is correct
16 Correct 18 ms 492 KB Output is correct
17 Correct 16 ms 480 KB Output is correct
18 Correct 21 ms 452 KB Output is correct
19 Execution timed out 3087 ms 6876 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 4 ms 300 KB Output is correct
12 Correct 6 ms 448 KB Output is correct
13 Correct 7 ms 460 KB Output is correct
14 Correct 11 ms 540 KB Output is correct
15 Correct 11 ms 536 KB Output is correct
16 Correct 18 ms 492 KB Output is correct
17 Correct 16 ms 480 KB Output is correct
18 Correct 21 ms 452 KB Output is correct
19 Execution timed out 3053 ms 20416 KB Time limit exceeded
20 Halted 0 ms 0 KB -