답안 #1110851

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1110851 2024-11-10T15:42:56 Z imarn Snowball (JOI21_ho_t2) C++14
33 / 100
844 ms 12952 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;
bool cmp(pll a,pll b){
    if(a.f==b.f)return a.s>b.s;
    else return a.f<b.f;
}
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 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 5 ms 336 KB Output is correct
5 Correct 4 ms 336 KB Output is correct
6 Correct 4 ms 336 KB Output is correct
7 Correct 3 ms 336 KB Output is correct
8 Correct 4 ms 336 KB Output is correct
9 Correct 3 ms 572 KB Output is correct
10 Correct 1 ms 504 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 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 336 KB Output is correct
16 Correct 4 ms 336 KB Output is correct
17 Correct 5 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 2 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 5 ms 336 KB Output is correct
5 Correct 4 ms 336 KB Output is correct
6 Correct 4 ms 336 KB Output is correct
7 Correct 3 ms 336 KB Output is correct
8 Correct 4 ms 336 KB Output is correct
9 Correct 3 ms 572 KB Output is correct
10 Correct 1 ms 504 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 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 336 KB Output is correct
16 Correct 4 ms 336 KB Output is correct
17 Correct 5 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 2 ms 336 KB Output is correct
20 Correct 39 ms 6480 KB Output is correct
21 Correct 40 ms 6480 KB Output is correct
22 Correct 40 ms 6480 KB Output is correct
23 Correct 44 ms 6904 KB Output is correct
24 Correct 121 ms 7240 KB Output is correct
25 Correct 840 ms 12944 KB Output is correct
26 Correct 844 ms 12952 KB Output is correct
27 Incorrect 788 ms 12616 KB Output isn't correct
28 Halted 0 ms 0 KB -