Submission #537636

# Submission time Handle Problem Language Result Execution time Memory
537636 2022-03-15T10:22:37 Z pavement Snowball (JOI21_ho_t2) C++17
100 / 100
126 ms 15840 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
#define int long long
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using db = double;
using ll = long long;
using ld = long double;
using ii = pair<int, int>;
using iii = tuple<int, int, int>;
using iiii = tuple<int, int, int, int>;
template<class key, class value = null_type, class cmp = less<key> >
using ordered_set = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

int N, Q, minl, maxr, curr, X[200005], L[200005], R[200005];
bool fL[200005], fR[200005];
priority_queue<ii, vector<ii>, greater<ii> > pq;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
    cin >> N >> Q;
    for (int i = 1; i <= N; i++) {
		cin >> X[i];
		if (i > 1) pq.emplace(X[i] - X[i - 1], i);
	}
	for (int i = 1, W; i <= Q; i++) {
		cin >> W;
		curr += W;
		minl = min(minl, curr);
		maxr = max(maxr, curr);
		while (!pq.empty() && pq.top().first <= maxr - minl) {
			int y = pq.top().second;
			if (W > 0) {
				fR[y - 1] = fL[y] = 1;
				R[y - 1] = L[y] = X[y] + minl;
			} else {
				assert(W != 0);
				fR[y - 1] = fL[y] = 1;
				R[y - 1] = L[y] = X[y - 1] + maxr;
			}
			pq.pop();
		}
	}
	for (int i = 1; i <= N; i++) {
		if (!fL[i]) L[i] = X[i] + minl;
		if (!fR[i]) R[i] = X[i] + maxr;
		cout << R[i] - L[i] << '\n';
	}
}

Compilation message

Main.cpp:33:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   33 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 1 ms 480 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 1 ms 476 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 1 ms 480 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 1 ms 476 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 25 ms 2384 KB Output is correct
21 Correct 27 ms 2248 KB Output is correct
22 Correct 24 ms 2004 KB Output is correct
23 Correct 20 ms 1992 KB Output is correct
24 Correct 26 ms 3052 KB Output is correct
25 Correct 113 ms 13920 KB Output is correct
26 Correct 107 ms 13928 KB Output is correct
27 Correct 112 ms 13480 KB Output is correct
28 Correct 115 ms 13664 KB Output is correct
29 Correct 108 ms 13300 KB Output is correct
30 Correct 90 ms 12600 KB Output is correct
31 Correct 85 ms 11948 KB Output is correct
32 Correct 99 ms 12208 KB Output is correct
33 Correct 9 ms 1876 KB Output is correct
34 Correct 95 ms 14312 KB Output is correct
35 Correct 126 ms 13680 KB Output is correct
36 Correct 104 ms 13900 KB Output is correct
37 Correct 99 ms 13748 KB Output is correct
38 Correct 118 ms 13644 KB Output is correct
39 Correct 108 ms 13752 KB Output is correct
40 Correct 93 ms 13772 KB Output is correct
41 Correct 26 ms 3020 KB Output is correct
42 Correct 79 ms 11748 KB Output is correct
43 Correct 109 ms 15416 KB Output is correct
44 Correct 30 ms 2872 KB Output is correct
45 Correct 73 ms 13344 KB Output is correct
46 Correct 107 ms 15588 KB Output is correct
47 Correct 100 ms 15836 KB Output is correct
48 Correct 104 ms 15840 KB Output is correct