답안 #203100

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
203100 2020-02-19T11:17:53 Z godwind Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
135 ms 7928 KB
// O O O O O O O O O O O O O O O OO O OO O OO O O O TTCH O TTTCH O TTTCH O O O O
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
// #include <random>
#include <iomanip>
#include <bitset>
#include <cassert>
 
using namespace std;
 
#define y1 y11
#define double long double
#define less less228
#define left left228
#define right right228
#define list list228
 
 
 
template<typename T> void uin(T &a, T b) {
    if (b < a) a = b;
}
template<typename T> void uax(T &a, T b) {
    if (b > a) a = b;
}
 
 
// random_device rnd;
 
// template<typename T> void shuffle(vector< T > &v) {
//     for (int i = 1; i < (int)v.size(); ++i) {
//         swap(v[rnd() % i], v[i]);
//     }
//     for (int i = (int)v.size() - 1; i; --i) {
//         swap(v[rnd() % i], v[i]);
//     }
// }
 
const int N = 200 * 1000 + 228;
 
int n;
pair<int, int> a[N];
int b[N];
int value[N], left[N], right[N];
int ans[N];
 
void aux(int l, int r, int x) {
    if (l == 1) {
        uax(right[r], x);
    }
    if (r == n + 1) {
        uax(left[l], x);
    }
}
 
void dodo() {
    for (int i = 1; i <= n + 1; ++i) {
        uax(left[i], left[i - 1]);
    }
    for (int i = n + 1; i; --i) {
        uax(right[i], right[i + 1]);
    }
    for (int i = 1; i <= n + 1; ++i) {
        value[i] = max(left[i], right[i]);
    }
}
 
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n + 1; ++i) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a + 1, a + n + 2);
    for (int i = 1; i <= n; ++i) {
        cin >> b[i];
    }
    sort(b + 1, b + n + 1);
    for (int i = 1; i <= n; ++i) {
        aux(i + 1, n + 1, a[i].first - b[i]);
        aux(1, i, a[i + 1].first - b[i]);
    }
    dodo();
    for (int i = 1; i <= n + 1; ++i) {
        ans[a[i].second] = value[i];
    }
    for (int i = 1; i <= n + 1; ++i) {
        cout << ans[i] << ' ';
    }
    cout << '\n';
    return 0;
}
// RU_023
 
 
// 
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 380 KB Output is correct
6 Correct 5 ms 248 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 380 KB Output is correct
6 Correct 5 ms 248 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 6 ms 376 KB Output is correct
18 Correct 6 ms 504 KB Output is correct
19 Correct 6 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 6 ms 376 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 6 ms 376 KB Output is correct
24 Correct 6 ms 504 KB Output is correct
25 Correct 6 ms 376 KB Output is correct
26 Correct 6 ms 584 KB Output is correct
27 Correct 6 ms 376 KB Output is correct
28 Correct 6 ms 376 KB Output is correct
29 Correct 5 ms 376 KB Output is correct
30 Correct 5 ms 504 KB Output is correct
31 Correct 5 ms 376 KB Output is correct
32 Correct 6 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 380 KB Output is correct
6 Correct 5 ms 248 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 6 ms 376 KB Output is correct
18 Correct 6 ms 504 KB Output is correct
19 Correct 6 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 6 ms 376 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 6 ms 376 KB Output is correct
24 Correct 6 ms 504 KB Output is correct
25 Correct 6 ms 376 KB Output is correct
26 Correct 6 ms 584 KB Output is correct
27 Correct 6 ms 376 KB Output is correct
28 Correct 6 ms 376 KB Output is correct
29 Correct 5 ms 376 KB Output is correct
30 Correct 5 ms 504 KB Output is correct
31 Correct 5 ms 376 KB Output is correct
32 Correct 6 ms 376 KB Output is correct
33 Correct 125 ms 7160 KB Output is correct
34 Correct 130 ms 7416 KB Output is correct
35 Correct 126 ms 7160 KB Output is correct
36 Correct 126 ms 7544 KB Output is correct
37 Correct 132 ms 7928 KB Output is correct
38 Correct 128 ms 7672 KB Output is correct
39 Correct 127 ms 6136 KB Output is correct
40 Correct 135 ms 6880 KB Output is correct
41 Correct 130 ms 6904 KB Output is correct
42 Correct 128 ms 6136 KB Output is correct
43 Correct 134 ms 6860 KB Output is correct
44 Correct 125 ms 6520 KB Output is correct
45 Correct 123 ms 6520 KB Output is correct
46 Correct 127 ms 6620 KB Output is correct
47 Correct 134 ms 6136 KB Output is correct
48 Correct 127 ms 5672 KB Output is correct
49 Correct 129 ms 6964 KB Output is correct
50 Correct 131 ms 6264 KB Output is correct
51 Correct 135 ms 7032 KB Output is correct
52 Correct 130 ms 6264 KB Output is correct
53 Correct 127 ms 6264 KB Output is correct