Submission #202047

# Submission time Handle Problem Language Result Execution time Memory
202047 2020-02-13T09:02:43 Z khohko Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
501 ms 17932 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ARRS ((ll)(4e5+100))
#define fr first
#define sc second
#define pb push_back
#define MX ((ll)(1e9+100))
#define MAX ((ll)(1e18+100))

ll n;
pair<ll,ll> a[ARRS];
ll b[ARRS];
ll ans[ARRS];
int main(){
	cin>>n;
	for(int i=0; i<=n; i++){
		cin>>a[i].fr;
		a[i].sc=i;
	}
	for(int i=0; i<n; i++){
		cin>>b[i];
	}
	sort(a,a+n+1);
	sort(b,b+n);
	multiset<ll> st;
	for(int i=0; i<n; i++)
		st.insert(a[i].fr-b[i]);
	for(int i=n; i>=0; i--){
		ans[a[i].sc]=*(--st.end());
		if(i)
		st.erase(st.find(a[i-1].fr-b[i-1]));
		st.insert(a[i].fr-b[i-1]);
	}
	for(int i=0; i<=n; i++){
		cout<<ans[i]<<" ";
	}
	cout<<endl;
 
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 248 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 380 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 248 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 380 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 7 ms 504 KB Output is correct
16 Correct 6 ms 632 KB Output is correct
17 Correct 8 ms 504 KB Output is correct
18 Correct 8 ms 504 KB Output is correct
19 Correct 8 ms 504 KB Output is correct
20 Correct 8 ms 504 KB Output is correct
21 Correct 8 ms 504 KB Output is correct
22 Correct 8 ms 504 KB Output is correct
23 Correct 7 ms 504 KB Output is correct
24 Correct 8 ms 504 KB Output is correct
25 Correct 8 ms 504 KB Output is correct
26 Correct 8 ms 504 KB Output is correct
27 Correct 8 ms 504 KB Output is correct
28 Correct 8 ms 504 KB Output is correct
29 Correct 7 ms 504 KB Output is correct
30 Correct 11 ms 504 KB Output is correct
31 Correct 8 ms 504 KB Output is correct
32 Correct 9 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 248 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 380 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 7 ms 504 KB Output is correct
16 Correct 6 ms 632 KB Output is correct
17 Correct 8 ms 504 KB Output is correct
18 Correct 8 ms 504 KB Output is correct
19 Correct 8 ms 504 KB Output is correct
20 Correct 8 ms 504 KB Output is correct
21 Correct 8 ms 504 KB Output is correct
22 Correct 8 ms 504 KB Output is correct
23 Correct 7 ms 504 KB Output is correct
24 Correct 8 ms 504 KB Output is correct
25 Correct 8 ms 504 KB Output is correct
26 Correct 8 ms 504 KB Output is correct
27 Correct 8 ms 504 KB Output is correct
28 Correct 8 ms 504 KB Output is correct
29 Correct 7 ms 504 KB Output is correct
30 Correct 11 ms 504 KB Output is correct
31 Correct 8 ms 504 KB Output is correct
32 Correct 9 ms 632 KB Output is correct
33 Correct 417 ms 16760 KB Output is correct
34 Correct 427 ms 17528 KB Output is correct
35 Correct 457 ms 16924 KB Output is correct
36 Correct 411 ms 17400 KB Output is correct
37 Correct 434 ms 17932 KB Output is correct
38 Correct 429 ms 17784 KB Output is correct
39 Correct 479 ms 16760 KB Output is correct
40 Correct 472 ms 16632 KB Output is correct
41 Correct 484 ms 16760 KB Output is correct
42 Correct 467 ms 16760 KB Output is correct
43 Correct 473 ms 16716 KB Output is correct
44 Correct 435 ms 16120 KB Output is correct
45 Correct 447 ms 16376 KB Output is correct
46 Correct 458 ms 16248 KB Output is correct
47 Correct 388 ms 16632 KB Output is correct
48 Correct 396 ms 16636 KB Output is correct
49 Correct 494 ms 17184 KB Output is correct
50 Correct 477 ms 17144 KB Output is correct
51 Correct 501 ms 17272 KB Output is correct
52 Correct 479 ms 17144 KB Output is correct
53 Correct 482 ms 17404 KB Output is correct