# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
878072 | 2023-11-24T04:21:20 Z | frostray8653 | Snowball (JOI21_ho_t2) | C++17 | 79 ms | 11416 KB |
// #pragma GCC optimize("Ofast,unroll-loops,O3") #include <bits/stdc++.h> #define int long long // #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define IO ios::sync_with_stdio(0), cin.tie(0) #define FOR(i, a, b) for (int i = a, I = b; i <= b; i++) using namespace std; void dbg() {;} template<class T, class ...U> void dbg(T a, U ...b) {cout << a << " "; dbg(b...);} void ent() {cout << "\n";} const int mod = 998244353; // const int mod = 1e9 + 7; // const int INF = 2e9; const int INF = 9e17; /// ------- Initialization End ------- const int N = 200005; int a[N]; int dx[N]; int bestl[N], bestr[N]; int ansl[N], ansr[N]; signed main() { IO; int n, m; cin >> n >> m; FOR(i, 1, n) cin >> a[i]; FOR(i, 1, m) cin >> dx[i]; int now = 0; int lft = 0, rgt = 0; FOR(i, 1, m) { now += dx[i]; lft = min(lft, now); rgt = max(rgt, now); bestl[i] = lft; bestr[i] = rgt; } ansl[1] = a[1] + bestl[m]; FOR(i, 1, n) { if (i == n) { ansr[i] = a[i] + bestr[m]; } else { int dif = a[i + 1] - a[i]; int l = 0, r = m + 1; while (l + 1 < r) { int mid = (l + r) >> 1; if (bestr[mid] - bestl[mid] >= dif) r = mid; else l = mid; } int id = l; int len = bestr[id] - bestl[id]; ansr[i + 0] = a[i + 0] + bestr[id]; ansl[i + 1] = a[i + 1] + bestl[id]; if (id < m) { if (bestr[id + 1] > bestr[id]) { ansr[i + 0] += dif - len; } else { ansl[i + 1] -= dif - len; } } } } FOR(i, 1, n) cout << ansr[i] - ansl[i] << "\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 8540 KB | Output is correct |
2 | Correct | 1 ms | 8540 KB | Output is correct |
3 | Correct | 1 ms | 8540 KB | Output is correct |
4 | Correct | 2 ms | 8540 KB | Output is correct |
5 | Correct | 1 ms | 8672 KB | Output is correct |
6 | Correct | 2 ms | 8568 KB | Output is correct |
7 | Correct | 2 ms | 8540 KB | Output is correct |
8 | Correct | 2 ms | 8540 KB | Output is correct |
9 | Correct | 2 ms | 8540 KB | Output is correct |
10 | Correct | 1 ms | 8540 KB | Output is correct |
11 | Correct | 1 ms | 8536 KB | Output is correct |
12 | Correct | 1 ms | 8792 KB | Output is correct |
13 | Correct | 1 ms | 8540 KB | Output is correct |
14 | Correct | 1 ms | 8540 KB | Output is correct |
15 | Correct | 2 ms | 8540 KB | Output is correct |
16 | Correct | 2 ms | 8540 KB | Output is correct |
17 | Correct | 1 ms | 8540 KB | Output is correct |
18 | Correct | 1 ms | 8540 KB | Output is correct |
19 | Correct | 1 ms | 8540 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 8540 KB | Output is correct |
2 | Correct | 1 ms | 8540 KB | Output is correct |
3 | Correct | 1 ms | 8540 KB | Output is correct |
4 | Correct | 2 ms | 8540 KB | Output is correct |
5 | Correct | 1 ms | 8672 KB | Output is correct |
6 | Correct | 2 ms | 8568 KB | Output is correct |
7 | Correct | 2 ms | 8540 KB | Output is correct |
8 | Correct | 2 ms | 8540 KB | Output is correct |
9 | Correct | 2 ms | 8540 KB | Output is correct |
10 | Correct | 1 ms | 8540 KB | Output is correct |
11 | Correct | 1 ms | 8536 KB | Output is correct |
12 | Correct | 1 ms | 8792 KB | Output is correct |
13 | Correct | 1 ms | 8540 KB | Output is correct |
14 | Correct | 1 ms | 8540 KB | Output is correct |
15 | Correct | 2 ms | 8540 KB | Output is correct |
16 | Correct | 2 ms | 8540 KB | Output is correct |
17 | Correct | 1 ms | 8540 KB | Output is correct |
18 | Correct | 1 ms | 8540 KB | Output is correct |
19 | Correct | 1 ms | 8540 KB | Output is correct |
20 | Correct | 18 ms | 8664 KB | Output is correct |
21 | Correct | 17 ms | 8536 KB | Output is correct |
22 | Correct | 16 ms | 8660 KB | Output is correct |
23 | Correct | 16 ms | 8540 KB | Output is correct |
24 | Correct | 20 ms | 8800 KB | Output is correct |
25 | Correct | 71 ms | 11348 KB | Output is correct |
26 | Correct | 72 ms | 11348 KB | Output is correct |
27 | Correct | 70 ms | 11108 KB | Output is correct |
28 | Correct | 73 ms | 11200 KB | Output is correct |
29 | Correct | 72 ms | 10832 KB | Output is correct |
30 | Correct | 67 ms | 10416 KB | Output is correct |
31 | Correct | 44 ms | 10068 KB | Output is correct |
32 | Correct | 41 ms | 10068 KB | Output is correct |
33 | Correct | 8 ms | 8796 KB | Output is correct |
34 | Correct | 79 ms | 11364 KB | Output is correct |
35 | Correct | 72 ms | 11088 KB | Output is correct |
36 | Correct | 73 ms | 11348 KB | Output is correct |
37 | Correct | 72 ms | 11088 KB | Output is correct |
38 | Correct | 70 ms | 11088 KB | Output is correct |
39 | Correct | 71 ms | 11108 KB | Output is correct |
40 | Correct | 57 ms | 11180 KB | Output is correct |
41 | Correct | 18 ms | 8540 KB | Output is correct |
42 | Correct | 42 ms | 10172 KB | Output is correct |
43 | Correct | 53 ms | 11320 KB | Output is correct |
44 | Correct | 18 ms | 8540 KB | Output is correct |
45 | Correct | 46 ms | 11068 KB | Output is correct |
46 | Correct | 50 ms | 11388 KB | Output is correct |
47 | Correct | 51 ms | 11376 KB | Output is correct |
48 | Correct | 51 ms | 11416 KB | Output is correct |