답안 #475906

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
475906 2021-09-24T12:08:10 Z ymm Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
318 ms 19396 KB
///
///   Let the voice of love take you higher!
///

#define _USE_MATH_DEFINES
#define FAST ios::sync_with_stdio(false),cin.tie(0);
#include <bits/stdc++.h>
#define Loop(x, l, r) for(ll x = ll(l); x < ll(r); ++x)
#define LoopR(x, l, r) for(ll x = ll(r)-1; x >= ll(l); --x)
#define all(x) x.begin(), x.end()
#define Kill(x) exit((cout << (x) << '\n', 0))
#define YN(flag) ((flag)? "YES": "NO")
#define F first
#define S second
typedef          long long   ll;
typedef unsigned long long  ull;
typedef std::pair<int,int>  pii;
typedef std::pair<ll ,ll >  pll;
using namespace std;

const int N = 200010;
pii a[N];
int b1[N];
int b2[N];
int ans[N];
set<pii, greater<pii>> s;
int n;


int main()
{
    FAST;
    cin >> n;
    Loop(i,0,n+1) cin >> a[i].F, a[i].S=i;
    Loop(i,0,n) cin >> b1[i];
    sort(b1, b1+n);
    sort(a, a+n+1);
    Loop(i,0,n) b2[i] = a[i+1].F;
    s.insert({0, -1});
    Loop(i,0,n) s.emplace(b2[i]-b1[i], i);
    Loop(i,0,n+1)
    {
        ans[a[i].S] = s.begin()->F;
        if(i==n) break;
        s.erase({b2[i]-b1[i],i});
        b2[i] = a[i].F;
        s.insert({b2[i]-b1[i],i});
    }
    Loop(i,0,n+1) cout << ans[i] << ' ';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 2 ms 460 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 3 ms 332 KB Output is correct
22 Correct 2 ms 332 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 2 ms 512 KB Output is correct
27 Correct 2 ms 460 KB Output is correct
28 Correct 2 ms 460 KB Output is correct
29 Correct 2 ms 332 KB Output is correct
30 Correct 2 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 1 ms 332 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 2 ms 460 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 3 ms 332 KB Output is correct
22 Correct 2 ms 332 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 2 ms 512 KB Output is correct
27 Correct 2 ms 460 KB Output is correct
28 Correct 2 ms 460 KB Output is correct
29 Correct 2 ms 332 KB Output is correct
30 Correct 2 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 246 ms 16952 KB Output is correct
34 Correct 267 ms 18828 KB Output is correct
35 Correct 229 ms 18200 KB Output is correct
36 Correct 227 ms 18756 KB Output is correct
37 Correct 236 ms 19396 KB Output is correct
38 Correct 223 ms 19196 KB Output is correct
39 Correct 304 ms 18096 KB Output is correct
40 Correct 281 ms 18248 KB Output is correct
41 Correct 309 ms 18300 KB Output is correct
42 Correct 297 ms 18204 KB Output is correct
43 Correct 299 ms 18100 KB Output is correct
44 Correct 205 ms 17476 KB Output is correct
45 Correct 210 ms 17604 KB Output is correct
46 Correct 214 ms 17528 KB Output is correct
47 Correct 188 ms 18116 KB Output is correct
48 Correct 181 ms 18032 KB Output is correct
49 Correct 315 ms 18664 KB Output is correct
50 Correct 318 ms 18568 KB Output is correct
51 Correct 305 ms 18564 KB Output is correct
52 Correct 300 ms 18608 KB Output is correct
53 Correct 295 ms 18628 KB Output is correct