Submission #991583

#TimeUsernameProblemLanguageResultExecution timeMemory
991583rsinventorJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
68 ms9312 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector <ll> vll; typedef vector<bool> vb; typedef vector <string> vs; typedef vector<char> vc; typedef pair<int, int> pii; typedef vector <pii> vpii; #define all(a) (a).begin(), (a).end() #define pb push_back #define endl "\n" int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vpii a(n+1); for(int i = 0; i < n+1; i++) { cin >> a[i].first; a[i].second = i; } vi b(n); for(int i = 0; i < n; i++) { cin >> b[i]; } sort(all(a)); sort(all(b)); vector<int> ans(n+1); int mx = 0; for(int i = 0; i < n; i++) { mx = max(mx, max(0, a[i].first-b[i])); } ans[a[a.size()-1].second] = mx; for(int i = n-1; i >=0; i--) { mx = max(mx, max(0, a[i+1].first-b[i])); ans[a[i].second] = mx; } for(int a: ans) { cout << a << " "; } cout << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...