답안 #515941

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
515941 2022-01-20T07:23:56 Z David_M Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
298 ms 43628 KB
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define FF first.first
#define FS first.second
#define pb push_back
using namespace std;
const ll N=1000006, INF=1e18, P=998244353;

ll q=1, n, m, x, y, z, l, r, c, k, b[N], f[N], ansl, ansr, ans, o, u, Ans[N];
vector <pii> v[N], V;
pii a[N];

void solve(){
    cin>>n;
    for(int i=0; i<=n; i++){
        cin>>a[i].F;
        a[i].S=i;
    }
    for (int i=0; i<n; i++){
        cin>>b[i];
    }

    sort(a, a+n+1);
    sort(b, b+n);

    set<pii> s;
    for (int i=0; i<n; i++){
        s.insert({b[i]-a[i+1].F, i});
    }
    Ans[a[0].S]=max(0, -(*s.begin()).F);
    for (int i=0; i<n; i++){
        s.erase({b[i]-a[i+1].F, i});
        s.insert({b[i]-a[i].F, i});
        Ans[a[i+1].S]=max(0, -(*s.begin()).F);
    }
    for (int i=0; i<=n; i++)cout<<Ans[i]<<" ";
}


main(){ios_base::sync_with_stdio(false), cin.tie(0);

	int T=1;
	//cin>>T;
    while(T--){
        solve();
    }

}

Compilation message

ho_t1.cpp:44:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   44 | main(){ios_base::sync_with_stdio(false), cin.tie(0);
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23756 KB Output is correct
2 Correct 12 ms 23792 KB Output is correct
3 Correct 12 ms 23804 KB Output is correct
4 Correct 12 ms 23756 KB Output is correct
5 Correct 11 ms 23732 KB Output is correct
6 Correct 11 ms 23756 KB Output is correct
7 Correct 13 ms 23804 KB Output is correct
8 Correct 11 ms 23756 KB Output is correct
9 Correct 12 ms 23756 KB Output is correct
10 Correct 12 ms 23756 KB Output is correct
11 Correct 13 ms 23744 KB Output is correct
12 Correct 13 ms 23756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23756 KB Output is correct
2 Correct 12 ms 23792 KB Output is correct
3 Correct 12 ms 23804 KB Output is correct
4 Correct 12 ms 23756 KB Output is correct
5 Correct 11 ms 23732 KB Output is correct
6 Correct 11 ms 23756 KB Output is correct
7 Correct 13 ms 23804 KB Output is correct
8 Correct 11 ms 23756 KB Output is correct
9 Correct 12 ms 23756 KB Output is correct
10 Correct 12 ms 23756 KB Output is correct
11 Correct 13 ms 23744 KB Output is correct
12 Correct 13 ms 23756 KB Output is correct
13 Correct 12 ms 23832 KB Output is correct
14 Correct 14 ms 23820 KB Output is correct
15 Correct 15 ms 23860 KB Output is correct
16 Correct 14 ms 23780 KB Output is correct
17 Correct 13 ms 23940 KB Output is correct
18 Correct 13 ms 23944 KB Output is correct
19 Correct 13 ms 23936 KB Output is correct
20 Correct 13 ms 23876 KB Output is correct
21 Correct 16 ms 23920 KB Output is correct
22 Correct 14 ms 23884 KB Output is correct
23 Correct 13 ms 23940 KB Output is correct
24 Correct 12 ms 23868 KB Output is correct
25 Correct 13 ms 23884 KB Output is correct
26 Correct 13 ms 23976 KB Output is correct
27 Correct 16 ms 23880 KB Output is correct
28 Correct 13 ms 23952 KB Output is correct
29 Correct 15 ms 23888 KB Output is correct
30 Correct 14 ms 23884 KB Output is correct
31 Correct 13 ms 23980 KB Output is correct
32 Correct 17 ms 23884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23756 KB Output is correct
2 Correct 12 ms 23792 KB Output is correct
3 Correct 12 ms 23804 KB Output is correct
4 Correct 12 ms 23756 KB Output is correct
5 Correct 11 ms 23732 KB Output is correct
6 Correct 11 ms 23756 KB Output is correct
7 Correct 13 ms 23804 KB Output is correct
8 Correct 11 ms 23756 KB Output is correct
9 Correct 12 ms 23756 KB Output is correct
10 Correct 12 ms 23756 KB Output is correct
11 Correct 13 ms 23744 KB Output is correct
12 Correct 13 ms 23756 KB Output is correct
13 Correct 12 ms 23832 KB Output is correct
14 Correct 14 ms 23820 KB Output is correct
15 Correct 15 ms 23860 KB Output is correct
16 Correct 14 ms 23780 KB Output is correct
17 Correct 13 ms 23940 KB Output is correct
18 Correct 13 ms 23944 KB Output is correct
19 Correct 13 ms 23936 KB Output is correct
20 Correct 13 ms 23876 KB Output is correct
21 Correct 16 ms 23920 KB Output is correct
22 Correct 14 ms 23884 KB Output is correct
23 Correct 13 ms 23940 KB Output is correct
24 Correct 12 ms 23868 KB Output is correct
25 Correct 13 ms 23884 KB Output is correct
26 Correct 13 ms 23976 KB Output is correct
27 Correct 16 ms 23880 KB Output is correct
28 Correct 13 ms 23952 KB Output is correct
29 Correct 15 ms 23888 KB Output is correct
30 Correct 14 ms 23884 KB Output is correct
31 Correct 13 ms 23980 KB Output is correct
32 Correct 17 ms 23884 KB Output is correct
33 Correct 232 ms 42312 KB Output is correct
34 Correct 197 ms 43212 KB Output is correct
35 Correct 205 ms 42556 KB Output is correct
36 Correct 218 ms 43076 KB Output is correct
37 Correct 208 ms 43628 KB Output is correct
38 Correct 196 ms 43364 KB Output is correct
39 Correct 270 ms 42420 KB Output is correct
40 Correct 276 ms 42224 KB Output is correct
41 Correct 257 ms 42436 KB Output is correct
42 Correct 267 ms 42400 KB Output is correct
43 Correct 264 ms 42304 KB Output is correct
44 Correct 251 ms 41792 KB Output is correct
45 Correct 210 ms 41864 KB Output is correct
46 Correct 232 ms 41792 KB Output is correct
47 Correct 221 ms 42312 KB Output is correct
48 Correct 198 ms 42324 KB Output is correct
49 Correct 260 ms 42904 KB Output is correct
50 Correct 267 ms 42904 KB Output is correct
51 Correct 271 ms 42872 KB Output is correct
52 Correct 297 ms 42912 KB Output is correct
53 Correct 298 ms 43004 KB Output is correct