답안 #438698

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
438698 2021-06-28T13:36:25 Z JovanB Snowball (JOI21_ho_t2) C++17
100 / 100
591 ms 11380 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;

const int MAXN = 200000;

ll levo[MAXN+5];
ll desno[MAXN+5];
ll x[MAXN+5];

ll pre[MAXN+5], minpref[MAXN+5], maxpref[MAXN+5];

const ll INF = 2000000000000000000LL;

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, m;
    cin >> n >> m;
    for(int i=1; i<=n; i++){
        cin >> x[i];
    }
    for(int i=1; i<=m; i++){
        cin >> pre[i];
        pre[i] += pre[i-1];
        maxpref[i] = max(maxpref[i-1], pre[i]);
        minpref[i] = min(minpref[i-1], pre[i]);
    }
    for(int i=1; i<=n; i++) levo[i] = desno[i] = x[i];
    x[0] = -INF;
    x[n+1] = INF;
    desno[0] = -INF;
    for(int i=1; i<=n; i++){
        ll l = x[i]+1, r = min(x[i+1], maxpref[m] + x[i]), res = x[i];
        while(l <= r){
            ll mid = (l+r)/2;
            int ind1 = lower_bound(maxpref+1, maxpref+1+m, mid - x[i]) - maxpref;
            ll x2 = minpref[ind1];
            if(x[i+1] + x2 >= mid){
                l = mid+1;
                res = mid;
            }
            else r = mid-1;
        }
        desno[i] = res;
    }
    for(int i=1; i<=n; i++){
        levo[i] = max(x[i] + minpref[m], desno[i-1]);
        cout << desno[i] - levo[i] << "\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 4 ms 460 KB Output is correct
5 Correct 4 ms 460 KB Output is correct
6 Correct 3 ms 460 KB Output is correct
7 Correct 3 ms 460 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 2 ms 448 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 4 ms 460 KB Output is correct
16 Correct 4 ms 452 KB Output is correct
17 Correct 4 ms 460 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 4 ms 460 KB Output is correct
5 Correct 4 ms 460 KB Output is correct
6 Correct 3 ms 460 KB Output is correct
7 Correct 3 ms 460 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 2 ms 448 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 4 ms 460 KB Output is correct
16 Correct 4 ms 452 KB Output is correct
17 Correct 4 ms 460 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 33 ms 4932 KB Output is correct
21 Correct 34 ms 5000 KB Output is correct
22 Correct 41 ms 4932 KB Output is correct
23 Correct 35 ms 4980 KB Output is correct
24 Correct 87 ms 5616 KB Output is correct
25 Correct 591 ms 11332 KB Output is correct
26 Correct 584 ms 11228 KB Output is correct
27 Correct 487 ms 11056 KB Output is correct
28 Correct 507 ms 10984 KB Output is correct
29 Correct 430 ms 10924 KB Output is correct
30 Correct 236 ms 10580 KB Output is correct
31 Correct 81 ms 10052 KB Output is correct
32 Correct 78 ms 10052 KB Output is correct
33 Correct 44 ms 1412 KB Output is correct
34 Correct 502 ms 11172 KB Output is correct
35 Correct 494 ms 10976 KB Output is correct
36 Correct 541 ms 11332 KB Output is correct
37 Correct 485 ms 11076 KB Output is correct
38 Correct 527 ms 11072 KB Output is correct
39 Correct 509 ms 10964 KB Output is correct
40 Correct 241 ms 11056 KB Output is correct
41 Correct 44 ms 4900 KB Output is correct
42 Correct 71 ms 10052 KB Output is correct
43 Correct 195 ms 11216 KB Output is correct
44 Correct 35 ms 4936 KB Output is correct
45 Correct 186 ms 11100 KB Output is correct
46 Correct 202 ms 11380 KB Output is correct
47 Correct 194 ms 11316 KB Output is correct
48 Correct 93 ms 11320 KB Output is correct