Submission #497647

# Submission time Handle Problem Language Result Execution time Memory
497647 2021-12-23T12:57:48 Z penguin133 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
96 ms 13980 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int A[200005], B[200005], ans[200005];
pair<int, int> X[200005];
main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	for(int i=1;i<=n+1;i++)cin >> A[i], X[i] = make_pair(A[i], i);
	for(int i=1;i<=n;i++)cin >> B[i];
	sort(X+1, X+n+2);
	sort(B+1, B+n+1);
	int cnt = 0;
	for(int i=1;i<=n;i++)cnt = max(cnt, X[i].first - B[i]);
	for(int i=n+1;i>=1;i--){
		if(i == n + 1)ans[X[i].second] = cnt;
		else{
			cnt = max(cnt, X[i+1].first - B[i]);
			ans[X[i].second] = cnt;
		}
	}
	for(int i=1;i<=n+1;i++)cout << ans[i] << " ";
}

Compilation message

ho_t1.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 324 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 0 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 0 ms 336 KB Output is correct
9 Correct 0 ms 336 KB Output is correct
10 Correct 0 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 324 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 0 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 0 ms 336 KB Output is correct
9 Correct 0 ms 336 KB Output is correct
10 Correct 0 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 0 ms 320 KB Output is correct
17 Correct 1 ms 464 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 2 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 2 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 464 KB Output is correct
26 Correct 1 ms 464 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 328 KB Output is correct
32 Correct 1 ms 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 324 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 0 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 0 ms 336 KB Output is correct
9 Correct 0 ms 336 KB Output is correct
10 Correct 0 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 0 ms 320 KB Output is correct
17 Correct 1 ms 464 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 2 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 2 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 464 KB Output is correct
26 Correct 1 ms 464 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 328 KB Output is correct
32 Correct 1 ms 464 KB Output is correct
33 Correct 96 ms 12944 KB Output is correct
34 Correct 81 ms 13508 KB Output is correct
35 Correct 81 ms 13032 KB Output is correct
36 Correct 85 ms 13480 KB Output is correct
37 Correct 91 ms 13980 KB Output is correct
38 Correct 82 ms 13768 KB Output is correct
39 Correct 87 ms 12744 KB Output is correct
40 Correct 86 ms 12692 KB Output is correct
41 Correct 80 ms 12884 KB Output is correct
42 Correct 86 ms 12784 KB Output is correct
43 Correct 81 ms 12692 KB Output is correct
44 Correct 88 ms 12436 KB Output is correct
45 Correct 81 ms 12424 KB Output is correct
46 Correct 82 ms 12232 KB Output is correct
47 Correct 75 ms 12544 KB Output is correct
48 Correct 76 ms 12744 KB Output is correct
49 Correct 86 ms 13164 KB Output is correct
50 Correct 87 ms 13128 KB Output is correct
51 Correct 82 ms 13116 KB Output is correct
52 Correct 81 ms 13256 KB Output is correct
53 Correct 84 ms 13128 KB Output is correct