Submission #909567

#TimeUsernameProblemLanguageResultExecution timeMemory
909567a_l_i_r_e_z_aJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
227 ms19028 KiB
// In the name of God #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<int, int> pii; #define pb push_back #define S second #define F first #define mp make_pair #define smax(x, y) (x) = max((x), (y)) #define smin(x, y) (x) = min((x), (y)) #define all(x) (x).begin(), (x).end() #define len(x) ((int)(x).size()) const int maxn = 2e5 + 5; const int inf = 1e9 + 7; int n, b[maxn], ans[maxn]; pii a[maxn]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for(int i = 0; i < n + 1; i++){ cin >> a[i].F; a[i].S = i; } for(int i = 0; i < n; i++) cin >> b[i]; sort(b, b + n); sort(a, a + n + 1); multiset<int> st; for(int i = 0; i < n; i++) st.insert(max(0, a[i + 1].F - b[i])); for(int i = 0; i < n + 1; i++){ ans[a[i].S] = (*st.rbegin()); if(i != n) st.erase(st.find(max(0, a[i + 1].F - b[i]))); st.insert(max(0, a[i].F - b[i])); } for(int i = 0; i < n + 1; 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...