제출 #207337

#제출 시각아이디문제언어결과실행 시간메모리
207337fishy15Just Long Neckties (JOI20_ho_t1)C++14
0 / 100
5 ms380 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<ll, int>> a; vector<ll> b; multiset<ll> cur; int ans[MAXN]; int main() { cin.tie(0)->sync_with_stdio(0); cin >> n; for (int i = 0; i < n + 1; i++) { ll x; cin >> x; a.push_back({x, i}); } for (int i = 0; i < n; i++) { ll 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] = *cur.rbegin(); 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] = *cur.rbegin(); } 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...