답안 #224021

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224021 2020-04-17T04:51:54 Z errorgorn Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
336 ms 16480 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=start-(start>end);x!=end-(start>end);x+=(start<end?1:-1))
#define all(x) x.begin(),x.end()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a, Args... args) { return max(a,MAX(args...)); }
template<typename... Args>
ll MIN(ll a, Args... args) { return min(a,MIN(args...)); }

#define indexed_set tree<ll, null_type, less<ll>,rb_tree_tag,tree_order_statistics_node_update>

int n;
vector<ii> a;
vector<int> b;
multiset<int> s;

int ans[200005];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	int t;
	rep (x,0,n+1){
		cin>>t;
		a.push_back(ii(t,x));
	}	
	
	rep(x,0,n){
		cin>>t;
		b.push_back(t);
	}
	
	sort(all(a));
	sort(all(b));
	
	rep(x,0,n){
		s.insert(max(a[x+1].first-b[x],0LL));
	}
	
	ans[a[0].second]=*(--s.end());
	
	rep(x,0,n){
		s.erase(s.find(max(a[x+1].first-b[x],0LL)));
		s.insert(max(a[x].first-b[x],0LL));
		ans[a[x+1].second]=*(--s.end());
	}
	
	rep(x,0,n+1) cout<<ans[x]<<" ";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 6 ms 512 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 6 ms 512 KB Output is correct
18 Correct 6 ms 512 KB Output is correct
19 Correct 6 ms 512 KB Output is correct
20 Correct 6 ms 512 KB Output is correct
21 Correct 6 ms 512 KB Output is correct
22 Correct 6 ms 512 KB Output is correct
23 Correct 6 ms 512 KB Output is correct
24 Correct 6 ms 512 KB Output is correct
25 Correct 6 ms 512 KB Output is correct
26 Correct 6 ms 512 KB Output is correct
27 Correct 6 ms 512 KB Output is correct
28 Correct 6 ms 512 KB Output is correct
29 Correct 6 ms 512 KB Output is correct
30 Correct 6 ms 512 KB Output is correct
31 Correct 6 ms 512 KB Output is correct
32 Correct 6 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 6 ms 512 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 6 ms 512 KB Output is correct
18 Correct 6 ms 512 KB Output is correct
19 Correct 6 ms 512 KB Output is correct
20 Correct 6 ms 512 KB Output is correct
21 Correct 6 ms 512 KB Output is correct
22 Correct 6 ms 512 KB Output is correct
23 Correct 6 ms 512 KB Output is correct
24 Correct 6 ms 512 KB Output is correct
25 Correct 6 ms 512 KB Output is correct
26 Correct 6 ms 512 KB Output is correct
27 Correct 6 ms 512 KB Output is correct
28 Correct 6 ms 512 KB Output is correct
29 Correct 6 ms 512 KB Output is correct
30 Correct 6 ms 512 KB Output is correct
31 Correct 6 ms 512 KB Output is correct
32 Correct 6 ms 512 KB Output is correct
33 Correct 225 ms 15432 KB Output is correct
34 Correct 245 ms 16100 KB Output is correct
35 Correct 228 ms 15580 KB Output is correct
36 Correct 283 ms 15968 KB Output is correct
37 Correct 248 ms 16480 KB Output is correct
38 Correct 241 ms 16224 KB Output is correct
39 Correct 300 ms 15196 KB Output is correct
40 Correct 315 ms 15328 KB Output is correct
41 Correct 296 ms 15460 KB Output is correct
42 Correct 294 ms 15328 KB Output is correct
43 Correct 336 ms 15336 KB Output is correct
44 Correct 194 ms 14688 KB Output is correct
45 Correct 200 ms 14816 KB Output is correct
46 Correct 199 ms 14684 KB Output is correct
47 Correct 185 ms 14944 KB Output is correct
48 Correct 199 ms 14944 KB Output is correct
49 Correct 311 ms 15672 KB Output is correct
50 Correct 324 ms 15840 KB Output is correct
51 Correct 324 ms 15888 KB Output is correct
52 Correct 312 ms 15768 KB Output is correct
53 Correct 316 ms 15712 KB Output is correct