Submission #867617

#TimeUsernameProblemLanguageResultExecution timeMemory
867617MongHwaJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
207 ms18616 KiB
#include <iostream> #include <vector> #include <algorithm> #include <set> using namespace std; #define X first #define Y second int ans[200001]; int arr[200001]; multiset<int> ms; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<pair<int, int>> v; for(int i = 0; i <= n; i++) { int x; cin >> x; v.push_back({x, i}); } for(int i = 0; i < n; i++) cin >> arr[i]; sort(v.begin(), v.end()); sort(arr, arr+n); for(int i = 0; i < n; i++) ms.insert(max(0, v[i].X-arr[i])); ans[v[n].Y] = *ms.rbegin(); for(int i = n-1; i >= 0; i--) { ms.erase(ms.find(max(0, v[i].X-arr[i]))); ms.insert(max(0, v[i+1].X-arr[i])); ans[v[i].Y] = *ms.rbegin(); } for(int i = 0; i <= n; i++) cout << ans[i] << ' '; cout << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...