Submission #207330

#TimeUsernameProblemLanguageResultExecution timeMemory
207330fishy15Just Long Neckties (JOI20_ho_t1)C++14
0 / 100
5 ms376 KiB
#include <iostream> #include <iomanip> #include <fstream> #include <vector> #include <array> #include <algorithm> #include <utility> #include <map> #include <queue> #include <set> #include <cmath> #define ll long long #define eps 1e-8 #define MOD 1000000007 #define INF 0x3f3f3f3f #define INFLL 0x3f3f3f3f3f3f3f3f // change if necessary #define MAXN 200000 using namespace std; int n; vector<pair<int, int>> a; vector<int> b; multiset<int> cur; int ans[MAXN]; int main() { cin.tie(0)->sync_with_stdio(0); cin >> n; for (int i = 0; i < n + 1; i++) { int x; cin >> x; a.push_back({x, i}); } for (int i = 0; i < n; i++) { int x; cin >> x; b.push_back(x); } sort(a.begin(), a.end()); sort(b.begin(), b.end()); for (int i = 0; i < n; i++) { cur.insert(abs(a[i + 1].first - b[i])); } ans[a[0].second] = *max_element(cur.begin(), cur.end()); for (int i = 1; i <= n; i++) { cur.erase(cur.find(abs(a[i].first - b[i - 1]))); cur.insert(abs(a[i - 1].first - b[i - 1])); ans[a[i].second] = *max_element(cur.begin(), cur.end()); } for (int i = 0; i <= n; i++) { cout << ans[i] << ' '; } cout << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...