Submission #230628

#TimeUsernameProblemLanguageResultExecution timeMemory
230628AlexLuchianovJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
337 ms18680 KiB
#include <iostream> #include <vector> #include <algorithm> #include <cassert> #include <cmath> #include <set> using namespace std; using ll = long long; int const nmax = 200000; pair<int,int> v[5 + nmax]; int b[5 + nmax], sol[5 + nmax]; multiset<int> myset; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for(int i = 1;i <= n + 1; i++) { cin >> v[i].first; v[i].second = i; } sort(v + 1, v + n + 1 + 1); for(int i = 1;i <= n; i++) cin >> b[i]; sort(b + 1, b + n + 1); for(int i = 1; i <= n; i++) myset.insert(max(0,v[i + 1].first - b[i])); sol[v[1].second] = *myset.rbegin(); for(int i = 2;i <= n + 1; i++){ myset.erase(myset.find(max(0, v[i].first - b[i - 1]))); myset.insert(max(0, v[i - 1].first - b[i - 1])); sol[v[i].second] = *myset.rbegin(); } for(int i = 1;i <= n + 1; i++) cout << sol[i] << " " ; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...