답안 #203095

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
203095 2020-02-19T11:08:33 Z godwind Just Long Neckties (JOI20_ho_t1) C++14
0 / 100
5 ms 376 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 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) {
        ans[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(a[i].second + 1, n + 1, a[i].first - b[i]);
        aux(1, a[i].second, a[i + 1].first - b[i]);
    }
    dodo();
    for (int i = 1; i <= n + 1; ++i) {
        cout << ans[i] << ' ';
    }
    cout << '\n';
    return 0;
}
// RU_023


// 
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -