Submission #1133545

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
11335452025-01-08 07:55:22nuutsnoyntonJust Long Neckties (JOI20_ho_t1)C++20
100 / 100
133 ms11744 KiB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n, m, r, x, y, i,p, j,cnt1,cnt, t,s, mx, mn, k;
cin >> n;
pair < ll, ll > P[n + 2];
for (i = 1; i <= n + 1; i ++) {
cin >> P[i].first;
P[i].second = i;
}
ll b[n + 2];
for (i = 1; i <= n; i++) {
cin >> b[i];
}
sort(b + 1, b + n + 1);
sort(P + 1, P + n + 2);
ll aragsh[n + 2], uragsh[n +2];
aragsh[n + 1] = uragsh[0] = 0;
for (i = n; i >= 1; i --) {
aragsh[i] = max(aragsh[i + 1], max(0ll, P[i + 1].first - b[i]));
}
for (i = 1; i <= n; i ++) {
uragsh[i] = max(uragsh[i - 1], max(0ll, P[i].first - b[i]));
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...