# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1234537 | Bui_Quoc_Cuong | Just Long Neckties (JOI20_ho_t1) | C++20 | 1092 ms | 3716 KiB |
#include <bits/stdc++.h>
#define ll long long
#define FOR(i, a, b) for(int i = a; i <= (int)b; i++)
#define FORD(i, a, b) for(int i = a; i >= (int)b; i--)
#define ALL(A) A.begin(), A.end()
using namespace std;
const int maxn = 200005;
int n;
int c[maxn], a[maxn];
int main(){
cin.tie(nullptr) -> sync_with_stdio(false);
#define taskname "kieuoanh"
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout);
}
cin >> n;
FOR(i, 1, n + 1) cin >> c[i];
FOR(i, 1, n) cin >> a[i];
sort(a + 1, a + 1 + n);
FOR(i, 1, n + 1){
int ans = 0;
vector <int> cur;
FOR(j, 1, n + 1) if(i != j) cur.push_back(c[j]);
sort(ALL(cur));
FOR(j, 1, n) ans = max(ans, max(0, cur[j - 1] - a[j]));
cout << ans << " ";
}
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... |