# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
227614 | Rakhmand | Just Long Neckties (JOI20_ho_t1) | C++14 | 5 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// I feel still alive.
// Created by existence on 18/04/2003.
// Copyright © 2020 Rakhman. All rights reserved.
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <random>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>
#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define y1 asdsaaa
#define nl '\n'
const long long mxn = 2e5 + 10;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
typedef long long llong;
using namespace std;
void istxt(bool yes){
if(yes == 1){
freopen("balancing.in", "r", stdin);
freopen("balancing.out", "w", stdout);
}else{
freopen("/Users/rakhmanabdirashov/Desktop/folder/Programming/Road2Master/Road2Master/input.txt", "r", stdin);
}
}
int n, a[mxn], b[mxn], su[mxn];
int main () {
ios;
//istxt(0);
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 = n; i >= 1; i--){
su[i] = max(su[i + 1], max(0, a[i + 1] - b[i]));
}
int pr = 0;
for(int i = 1; i <= n + 1; i++){
cout << max(su[i], pr) << ' ';
pr = max(pr, max(0, a[i] - b[i]));
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |