제출 #877451

#제출 시각아이디문제언어결과실행 시간메모리
877451hasan2006Just Long Neckties (JOI20_ho_t1)C++17
100 / 100
202 ms31532 KiB
#include <bits/stdc++.h>

using namespace std;

#define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define rall(s) s.rbegin(),s.rend()
#define all(s) s.begin(),s.end()
#define pb push_back
#define se second
#define fi first
#define ll long long
#define ld long double
#define YES cout<<"YES\n"
#define Yes cout<<"Yes\n"
#define yes cout<<"yes\n"
#define NO cout<<"NO\n"
#define No cout<<"No\n"
#define no cout<<"no\n"


const int N = 5e5 + 9 , mod = 1e9 + 7;
ll   a[N] = {}, b[N] , c[N] , d[N] , dp[N];


void solve()
{
    ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
    cin>>n;
    vector<pair<int,int>>v;
    for(i = 1; i <= n + 1; i++){
        cin>>x;
        v.pb({x , i});
    }
    for(i = 1; i <= n; i++)
        cin>>a[i];
    v.pb({0 , 0});
    sort(all(v));
    multiset<ll>st;
    sort(a + 1 , a + n + 1);
    for(i = 1; i <= n; i++){
        d[i] = c[i] = v[i].fi - a[i];
        d[i] += v[i + 1].fi - v[i].fi;
        st.insert(d[i]);
    }
    for(i = 1; i <= n; i++){
        dp[v[i].se] = *st.rbegin();
        st.erase(st.find(d[i]));
        st.insert(c[i]);
    }
    dp[v[n + 1].se] = *st.rbegin();
    for(i = 1; i <= n + 1; i++)
        cout<<dp[i]<<" ";
}

int main(){
    TL;
/*    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
int t = 1;
//cin>>t;
while(t--)
     {
     solve();
     }
}
// Author : حسن

컴파일 시 표준 에러 (stderr) 메시지

ho_t1.cpp: In function 'void solve()':
ho_t1.cpp:27:8: warning: unused variable 'q' [-Wunused-variable]
   27 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |        ^
ho_t1.cpp:27:16: warning: unused variable 'j' [-Wunused-variable]
   27 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                ^
ho_t1.cpp:27:20: warning: unused variable 'm' [-Wunused-variable]
   27 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                    ^
ho_t1.cpp:27:26: warning: unused variable 'z' [-Wunused-variable]
   27 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                          ^
ho_t1.cpp:27:29: warning: unused variable 's' [-Wunused-variable]
   27 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                             ^
ho_t1.cpp:27:37: warning: unused variable 'f' [-Wunused-variable]
   27 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                     ^
ho_t1.cpp:27:40: warning: unused variable 'l' [-Wunused-variable]
   27 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                        ^
ho_t1.cpp:27:44: warning: unused variable 'r' [-Wunused-variable]
   27 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                            ^
ho_t1.cpp:27:48: warning: unused variable 'k' [-Wunused-variable]
   27 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                                ^
ho_t1.cpp:27:56: warning: unused variable 'y' [-Wunused-variable]
   27 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                                        ^
ho_t1.cpp:27:60: warning: unused variable 'mn' [-Wunused-variable]
   27 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                                            ^~
ho_t1.cpp:27:73: warning: unused variable 'mx' [-Wunused-variable]
   27 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                                                         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...