# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
878066 | 2023-11-24T04:06:48 Z | frostray8653 | Snowball (JOI21_ho_t2) | C++17 | 2 ms | 8660 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; } a[0] = -INF; a[n + 1] = INF; FOR(i, 0, n) { int dif = a[i + 1] - a[i]; int l = 1, 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; } /* 4 3 -2 3 5 8 2 -4 7 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | 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 | 8660 KB | Output is correct |
6 | Correct | 2 ms | 8536 KB | Output is correct |
7 | Correct | 2 ms | 8540 KB | Output is correct |
8 | Correct | 2 ms | 8552 KB | Output is correct |
9 | Correct | 2 ms | 8540 KB | Output is correct |
10 | Correct | 2 ms | 8540 KB | Output is correct |
11 | Correct | 2 ms | 8540 KB | Output is correct |
12 | Correct | 1 ms | 8540 KB | Output is correct |
13 | Correct | 1 ms | 8540 KB | Output is correct |
14 | Incorrect | 1 ms | 8540 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | 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 | 8660 KB | Output is correct |
6 | Correct | 2 ms | 8536 KB | Output is correct |
7 | Correct | 2 ms | 8540 KB | Output is correct |
8 | Correct | 2 ms | 8552 KB | Output is correct |
9 | Correct | 2 ms | 8540 KB | Output is correct |
10 | Correct | 2 ms | 8540 KB | Output is correct |
11 | Correct | 2 ms | 8540 KB | Output is correct |
12 | Correct | 1 ms | 8540 KB | Output is correct |
13 | Correct | 1 ms | 8540 KB | Output is correct |
14 | Incorrect | 1 ms | 8540 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |