답안 #438696

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
438696 2021-06-28T13:33:25 Z JovanB Snowball (JOI21_ho_t2) C++17
0 / 100
5 ms 460 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 = l;
        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 5 ms 460 KB Output is correct
6 Correct 5 ms 460 KB Output is correct
7 Incorrect 3 ms 460 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 5 ms 460 KB Output is correct
6 Correct 5 ms 460 KB Output is correct
7 Incorrect 3 ms 460 KB Output isn't correct
8 Halted 0 ms 0 KB -