Submission #1158494

#TimeUsernameProblemLanguageResultExecution timeMemory
1158494crispxxJust Long Neckties (JOI20_ho_t1)C++20
0 / 100
0 ms320 KiB
#include <bits/stdc++.h> using namespace std; #define nl '\n' signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(n + 1), b(n); for(auto &x : a) cin >> x; for(auto &x : b) cin >> x; sort(b.begin(), b.end()); for(int i = 0; i < n + 1; i++) { map<int, int> mp; for(int j = 0; j < n + 1; j++) { if(i == j) continue; mp[a[j]]++; } int res = 0; for(int j = 0; j < n; j++) { auto it = mp.upper_bound(b[j]); if(it == mp.end()) { it = prev(it); } int v = it -> first; res = max(res, max(0, v - b[j])); if(--mp[v] == 0) mp.erase(v); } cout << res << ' '; } cout << nl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...