답안 #1110848

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1110848 2024-11-10T15:40:27 Z imarn Snowball (JOI21_ho_t2) C++14
33 / 100
809 ms 16712 KB
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plx pair<ll,int>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vvi vector<vi>
#define pp pair<ll,int>
#define ub(x,i) upper_bound(all(x),i)-x.begin()
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n,q;cin>>n>>q;
    ll x[n+1];for(int i=1;i<=n;i++)cin>>x[i];
    vector<pll> w(q+1),ww(q+1);w[0]={0,0};for(int i=1;i<=q;i++)cin>>w[i].f,w[i].f+=w[i-1].f,w[i].s=i,ww[i]={-w[i].f,w[i].s};
    ll t=2e16,t2=2e16;
    sort(all(w));
    sort(all(ww));
    ll l[n+1],r[n+1];
    for(int i=1;i<=n;i++){
        l[i]=x[i]+w[0].f,r[i]=x[i]+w[q].f;
        if(i>1)l[i]=max(l[i],x[i-1]);
        if(i<n)r[i]=min(r[i],x[i+1]);
    }
    for(int i=q;i>=0;i--){
        t=min(t,w[i].s);
        w[i].s=min(t,w[i].s);
        t2=min(t2,ww[i].s);
        ww[i].s=min(t2,ww[i].s);
    }
    for(int i=2;i<=n;i++){
        if(r[i-1]<=l[i])continue;
        ll tl=l[i],tr=r[i-1]+1;
        while(tl<tr){
            ll md=(tl+tr)>>1;ll lf,rg;
            lf = lower_bound(all(w),make_pair(md-x[i-1],-1ll))->s;
            rg=lower_bound(all(ww),make_pair(x[i]-md+1,-1ll))->s;
            if(lf<rg)tl=md+1;
            else tr=md;
        }r[i-1]=tl-1;
        l[i]=tl-1;
    }
    for(int i=1;i<=n;i++){
        cout<<r[i]-l[i]<<'\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 5 ms 592 KB Output is correct
5 Correct 4 ms 592 KB Output is correct
6 Correct 4 ms 592 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 4 ms 592 KB Output is correct
9 Correct 3 ms 592 KB Output is correct
10 Correct 1 ms 592 KB Output is correct
11 Correct 2 ms 592 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 5 ms 592 KB Output is correct
16 Correct 5 ms 592 KB Output is correct
17 Correct 3 ms 400 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 5 ms 592 KB Output is correct
5 Correct 4 ms 592 KB Output is correct
6 Correct 4 ms 592 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 4 ms 592 KB Output is correct
9 Correct 3 ms 592 KB Output is correct
10 Correct 1 ms 592 KB Output is correct
11 Correct 2 ms 592 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 5 ms 592 KB Output is correct
16 Correct 5 ms 592 KB Output is correct
17 Correct 3 ms 400 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 756 KB Output is correct
20 Correct 37 ms 8784 KB Output is correct
21 Correct 36 ms 8528 KB Output is correct
22 Correct 44 ms 8468 KB Output is correct
23 Correct 43 ms 8316 KB Output is correct
24 Correct 113 ms 8776 KB Output is correct
25 Correct 789 ms 16712 KB Output is correct
26 Correct 809 ms 16620 KB Output is correct
27 Incorrect 750 ms 16200 KB Output isn't correct
28 Halted 0 ms 0 KB -