답안 #203098

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
203098 2020-02-19T11:13:33 Z godwind Just Long Neckties (JOI20_ho_t1) C++14
0 / 100
7 ms 632 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];
    }
    vector<int> c(n + 1);
    for (int x = 1; x <= n + 1; ++x) {
        vector<int> A;
        vector<int> B;
        for (int i = 1; i <= n + 1; ++i) {
            if (i != x) A.push_back(a[i].first);
            if (i <= n) B.push_back(b[i]);
        }
        sort(A.begin(), A.end());
        sort(B.begin(), B.end());
        c[x] = 0;
        for (int i = 0; i < n; ++i) {
            uax(c[x], A[i] - B[i]);
        }
    }
    for (int i = 1; i <= n + 1; ++i) {
        cout << c[i] << ' ';
    }
    cout << endl;
    // 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 Correct 5 ms 376 KB Output is correct
2 Runtime error 7 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Runtime error 7 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Runtime error 7 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -