답안 #1110858

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1110858 2024-11-10T16:05:40 Z imarn Snowball (JOI21_ho_t2) C++14
33 / 100
848 ms 15688 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 mn =0,mx=0;
    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},ww[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},mx=max(mx,w[i].f),mn=min(mn,w[i].f);
    ll t=2e16,t2=2e16;
    ll l[n+1],r[n+1];
    for(int i=1;i<=n;i++){
        l[i]=x[i]+mn,r[i]=x[i]+mx;
        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=1;i<=q;i++){
        w[i]=max(w[i],w[i-1]);
        ww[i]=max(ww[i],ww[i-1]);
    }
    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';
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:24:8: warning: unused variable 't' [-Wunused-variable]
   24 |     ll t=2e16,t2=2e16;
      |        ^
Main.cpp:24:15: warning: unused variable 't2' [-Wunused-variable]
   24 |     ll t=2e16,t2=2e16;
      |               ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 544 KB Output is correct
4 Correct 4 ms 336 KB Output is correct
5 Correct 5 ms 592 KB Output is correct
6 Correct 4 ms 336 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 3 ms 592 KB Output is correct
9 Correct 3 ms 336 KB Output is correct
10 Correct 2 ms 336 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 592 KB Output is correct
16 Correct 4 ms 336 KB Output is correct
17 Correct 3 ms 592 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 472 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 544 KB Output is correct
4 Correct 4 ms 336 KB Output is correct
5 Correct 5 ms 592 KB Output is correct
6 Correct 4 ms 336 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 3 ms 592 KB Output is correct
9 Correct 3 ms 336 KB Output is correct
10 Correct 2 ms 336 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 592 KB Output is correct
16 Correct 4 ms 336 KB Output is correct
17 Correct 3 ms 592 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 472 KB Output is correct
20 Correct 22 ms 7752 KB Output is correct
21 Correct 21 ms 6480 KB Output is correct
22 Correct 18 ms 6480 KB Output is correct
23 Correct 25 ms 6736 KB Output is correct
24 Correct 107 ms 7188 KB Output is correct
25 Correct 833 ms 15064 KB Output is correct
26 Correct 848 ms 12980 KB Output is correct
27 Incorrect 834 ms 15688 KB Output isn't correct
28 Halted 0 ms 0 KB -