답안 #493793

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
493793 2021-12-13T02:42:38 Z Biaz Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
238 ms 23336 KB
#include <bits/stdc++.h>
#define int long long
#define double long double
#define Nanase_Kurumi_aka_menhera_chan_is_mine ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pi pair<int, int>
#define ALL(i) i.begin(),i.end()
#define gcd(i,j) __gcd(i,j)
#define fi first
#define se second
#define eps 0.00000001
#define ist insert
#define DNE nullptr
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC optimize("O2")
int max(int x,int y){return x>=y?x:y;}
int min(int x,int y){return x>=y?y:x;}
using namespace std;
typedef long long ll;
const int N=200005;
const int M=100000005;
const int MOD=998244353;//1000000007;
const int INF=2147483647;//1000000000000000;

int n;
pi a[N];
int res[N],b[N];
multiset<int>st;
inline void sol(){
    cin >>n;
    for (int i=1;i<=n+1;i++)
        cin >>a[i].fi,a[i].se=i;
    for (int i=1;i<=n;i++)
        cin >>b[i];
    sort(a+1,a+n+2);sort(b+1,b+n+1);
    vector<int> c(n+1);
    for (int i=1;i<=n;i++)
        st.ist(max(0,a[i].fi-b[i])),c[i]=a[i].fi;
    res[a[n+1].se]=*st.rbegin();
    int pre=a[n+1].fi;
    for (int i=n;i>=1;i--){
        st.erase(max(0,a[i].fi-b[i]));
        st.ist(max(0,pre-b[i]));
        res[a[i].se]=*st.rbegin();
        pre=a[i].fi;
    }
    for (int i=1;i<=n+1;i++)
        cout <<res[i]<<' ';

}
signed main(){
    Nanase_Kurumi_aka_menhera_chan_is_mine
    int _=1;
    //cin >>_;
    while (_--) sol();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 460 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 2 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 2 ms 460 KB Output is correct
22 Correct 2 ms 460 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 460 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 1 ms 460 KB Output is correct
29 Correct 1 ms 460 KB Output is correct
30 Correct 1 ms 460 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 460 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 2 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 2 ms 460 KB Output is correct
22 Correct 2 ms 460 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 460 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 1 ms 460 KB Output is correct
29 Correct 1 ms 460 KB Output is correct
30 Correct 1 ms 460 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
33 Correct 184 ms 18220 KB Output is correct
34 Correct 176 ms 22760 KB Output is correct
35 Correct 157 ms 22084 KB Output is correct
36 Correct 179 ms 22564 KB Output is correct
37 Correct 188 ms 23336 KB Output is correct
38 Correct 166 ms 23052 KB Output is correct
39 Correct 227 ms 21964 KB Output is correct
40 Correct 196 ms 21828 KB Output is correct
41 Correct 204 ms 22084 KB Output is correct
42 Correct 221 ms 22068 KB Output is correct
43 Correct 230 ms 21856 KB Output is correct
44 Correct 184 ms 21296 KB Output is correct
45 Correct 177 ms 21460 KB Output is correct
46 Correct 190 ms 21268 KB Output is correct
47 Correct 146 ms 21972 KB Output is correct
48 Correct 143 ms 21968 KB Output is correct
49 Correct 212 ms 22588 KB Output is correct
50 Correct 225 ms 22572 KB Output is correct
51 Correct 218 ms 22528 KB Output is correct
52 Correct 238 ms 22572 KB Output is correct
53 Correct 227 ms 22556 KB Output is correct