답안 #762918

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
762918 2023-06-22T01:24:25 Z CDuong Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
0 ms 340 KB
/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,fma,bmi,bmi2,sse4.2,popcnt,lzcnt")
*/

#include <bits/stdc++.h>
#define taskname ""
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define int long long
#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
using namespace std;

const int mxN = 2e5 + 5;
const int mod = 1e9 + 7;
const ll oo = 1e18;

int n;
int a[mxN], b[mxN], pref[mxN], suff[mxN];

void solve() {
	cin >> n;
	for(int i = 1; i <= n + 1; ++i) cin >> a[i];
	for(int i = 1; i <= n; ++i) cin >> b[i];
	sort(a + 1, a + n + 2);
	sort(b + 1, b + n + 1);
	for(int i = 1; i <= n; ++i) {
		pref[i] = max(pref[i - 1], max(a[i] - b[i], 0ll));
	}	
	for(int i = n + 1; i >= 2; --i) {
		suff[i] = max(suff[i + 1], max(a[i] - b[i - 1], 0ll));
	}
	for(int i = 1; i <= n + 1; ++i) {
		cout << max(pref[i - 1], suff[i + 1]) << " \n"[i == n + 1];
	}
}

signed main() {

#ifndef CDuongg
    if(fopen(taskname".inp", "r"))
        assert(freopen(taskname".inp", "r", stdin)), assert(freopen(taskname".out", "w", stdout));
#else
    freopen("bai3.inp", "r", stdin);
    freopen("bai3.out", "w", stdout);
    auto start = chrono::high_resolution_clock::now();
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int t = 1; //cin >> t;
	while(t--) solve();

#ifdef CDuongg
	auto end = chrono::high_resolution_clock::now();
	cout << "\n"; for(int i = 1; i <= 100; ++i) cout << '=';
	cout << "\nExecution time: " << chrono::duration_cast<chrono::milliseconds> (end - start).count() << "[ms]" << endl;
#endif

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