답안 #914414

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914414 2024-01-22T05:10:15 Z ReLice Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
87 ms 17892 KB
#include <bits/stdc++.h>
#define ll long long
#define str string
#define ins insert
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz size()
#define vll vector<ll>
#define bc back()
#define arr array
#define pll vector<pair<ll,ll>>
using namespace std;
template <class _T>
bool chmin(_T &x, const _T &y){
    bool f=0;
    if (x>y){x=y;f=1;}
    return f;
}
template <class _T>
bool chmax(_T &x, const _T &y){
    bool f=0;
    if (x<y){x=y;f=1;}
    return f;
}
//void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
void start(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
const ll inf=1e18+7;
const ll mod=1e9+7;
const ll N=1e5+7;
const ld eps=1e-9;
void solve(){
    ll i,j;
    ll n;
    cin>>n;
    vll a(n+5),b(n+1,0);
    pll v(1,{0,0});
    for(i=1;i<=1+n;i++) {
        cin>>a[i];
        v.pb({a[i],i});
    }
    sort(all(v));
    for(i=1;i<=n;i++) cin>>b[i];
    sort(all(b));
    ll pref[n+5],suf[n+5];
    pref[0]=suf[n+2]=0;
    for(i=1;i<=n;i++) pref[i]=max(pref[i-1],max(v[i].fr-b[i],0ll));
    for(i=n+1;i>1;i--) suf[i]=max(suf[i+1],max(v[i].fr-b[i-1],0ll));
    ll ans[n+5];
    for(i=1;i<=n+1;i++) ans[v[i].sc]=max(pref[i-1],suf[i+1]);
    for(i=1;i<=n+1;i++) cout<<ans[i]<<' ';
    cout<<endl;

}

signed main(){
	start();
    ll t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}
/*



*/

Compilation message

ho_t1.cpp: In function 'void solve()':
ho_t1.cpp:46:10: warning: unused variable 'j' [-Wunused-variable]
   46 |     ll i,j;
      |          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 456 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 456 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 1 ms 632 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 2 ms 584 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 1 ms 472 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 1 ms 604 KB Output is correct
32 Correct 1 ms 472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 456 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 1 ms 632 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 2 ms 584 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 1 ms 472 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 1 ms 604 KB Output is correct
32 Correct 1 ms 472 KB Output is correct
33 Correct 75 ms 16064 KB Output is correct
34 Correct 77 ms 16832 KB Output is correct
35 Correct 75 ms 17092 KB Output is correct
36 Correct 76 ms 17892 KB Output is correct
37 Correct 77 ms 17348 KB Output is correct
38 Correct 80 ms 17012 KB Output is correct
39 Correct 73 ms 16068 KB Output is correct
40 Correct 78 ms 16068 KB Output is correct
41 Correct 75 ms 16452 KB Output is correct
42 Correct 78 ms 16324 KB Output is correct
43 Correct 76 ms 15916 KB Output is correct
44 Correct 72 ms 15368 KB Output is correct
45 Correct 72 ms 15816 KB Output is correct
46 Correct 82 ms 15548 KB Output is correct
47 Correct 69 ms 15932 KB Output is correct
48 Correct 71 ms 16320 KB Output is correct
49 Correct 75 ms 16584 KB Output is correct
50 Correct 87 ms 16544 KB Output is correct
51 Correct 76 ms 16376 KB Output is correct
52 Correct 75 ms 16576 KB Output is correct
53 Correct 80 ms 16832 KB Output is correct