제출 #1237395

#제출 시각아이디문제언어결과실행 시간메모리
1237395nerrrminJust Long Neckties (JOI20_ho_t1)C++20
0 / 100
1 ms392 KiB
#include<bits/stdc++.h> #define endl '\n' #define pb push_back using namespace std; const int maxn = 2e5 + 10; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int n; vector < pair < int, int > > a, b; int ans[maxn]; int main() { speed(); cin >> n; int val; for (int i = 1; i <= n+1; ++ i) { cin >> val; a.pb({val, i}); } for (int i = 1; i <= n; ++ i) { cin >> val; b.pb({val, i});//b[i]; } sort(a.begin(), a.end()); sort(b.begin(), b.end()); // sort(a+1, a+n+1+1); // sort(b+1, b+n+1); multiset < int > s; for (int i = 0; i < n; ++ i) s.insert(abs(a[i+1].first - b[i].first)); ans[a[0].second] = *s.rbegin(); for (int i = 1; i <= n; ++ i) { int other = abs(a[i].first - b[i-1].first); s.erase(s.find(other)); int newone = abs(a[i-1].first - b[i-1].first); s.insert(newone); ans[a[i].second] = *s.rbegin(); } for (int i = 1; i <= n+1; ++ i) cout << ans[i] << " "; cout << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...