Submission #596027

#TimeUsernameProblemLanguageResultExecution timeMemory
596027ioiJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
105 ms13932 KiB
#include<bits/stdc++.h> using namespace std; #define debug(x) cout << '[' << #x << " is: " << x << "] " << endl; #define inF freopen("cardgame.in" , "r" , stdin); #define outF freopen("cardgame.out" , "w" , stdout); #define imod(a , n) (a % n + n ) % n #define sor(v) sort(v.begin() , v.end()); #define print(v) for(auto f : v ) cout << f << " " ; #define rsor(v) sort(v.rbegin() , v.rend()); #define rev(v) reverse(v.begin() , v.end()); #define scan(v)for(auto &it : v)cin >> it ; #define ll long long #define logar(x , y) log(x) / log(y) #define __sum(n) n * (n + 1) / 2 #define __lcm(a , b) a / __gcd(a , b) * b #define pii pair<int , int > #define fastio ios_base::sync_with_stdio(false);cin.tie(0); #define int ll const int N = 3e5 + 3, M = N * 4 , MX = 2e4 + 40; const ll MOD = 998244353 , oo = 1e9 + 9 , OO = 1e18 , mod = MOD ; const double pi = acos(-1) , eps = 1e-17 ; int di[] = {1 , -1 , 0 , 0}; int dj[] = {0 , 0 , 1 , -1}; int32_t main() { // inF; // inF;outF; fastio; //Welcome back without <TAWJIHI> int n ; cin >> n ; vector<pair<int , int > > v ; for(int i = 0 ; i < n + 1 ; i ++){ int a ; cin >> a ; v.push_back({a , i}); } sort(v.begin() , v.end()); vector<int> b (n); for(auto &it : b)cin >> it ; sort(b.begin() , b.end()); int suff[n + 1] = {}; for(int i = n - 1 ; ~i ; i --){ suff[i] = max(suff[i + 1] , v[i + 1].first - b[i]); } int mx = 0 ; int ans[n + 1] = {}; for(int i = 0 ; i < n + 1; i ++ ){ ans[v[i].second] = max(mx , suff[i]); mx = max(mx , v[i].first - b[i]); } for(int i = 0 ; i < n + 1 ; i ++)cout << ans[i] << " " ; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...