답안 #509607

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
509607 2022-01-14T07:18:17 Z CSQ31 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
261 ms 9924 KB
#include <bits/stdc++.h>
using namespace std;
int b[200001],s[200001];
int ans[200001];
array<int,2>a[200001];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n+1;i++){
		cin>>a[i][0];
		a[i][1] = i;
	}
	for(int i=0;i<n;i++)cin>>b[i];
	sort(b,b+n);
	sort(a,a+n+1);
	for(int i=n;i>0;i--){
		s[i] = max(0,a[i][0] - b[i-1]);
		if(i!=n)s[i] = max(s[i],s[i+1]);
	}
	int cur = 0;
	for(int i=0;i<=n;i++){
		ans[a[i][1]] = cur;
		if(i!=n){
			ans[a[i][1]] = max(ans[a[i][1]],s[i+1]);
			cur=max(cur,a[i][0]-b[i]);
		}
	}
	for(int i=0;i<=n;i++)cout<<ans[i]<<" ";
	
	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 288 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 2 ms 352 KB Output is correct
15 Correct 2 ms 312 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 3 ms 308 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 3 ms 316 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 3 ms 332 KB Output is correct
22 Correct 2 ms 308 KB Output is correct
23 Correct 3 ms 308 KB Output is correct
24 Correct 3 ms 332 KB Output is correct
25 Correct 3 ms 332 KB Output is correct
26 Correct 2 ms 332 KB Output is correct
27 Correct 3 ms 316 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 2 ms 332 KB Output is correct
30 Correct 2 ms 332 KB Output is correct
31 Correct 2 ms 308 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 288 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 2 ms 352 KB Output is correct
15 Correct 2 ms 312 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 3 ms 308 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 3 ms 316 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 3 ms 332 KB Output is correct
22 Correct 2 ms 308 KB Output is correct
23 Correct 3 ms 308 KB Output is correct
24 Correct 3 ms 332 KB Output is correct
25 Correct 3 ms 332 KB Output is correct
26 Correct 2 ms 332 KB Output is correct
27 Correct 3 ms 316 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 2 ms 332 KB Output is correct
30 Correct 2 ms 332 KB Output is correct
31 Correct 2 ms 308 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 225 ms 9116 KB Output is correct
34 Correct 205 ms 9536 KB Output is correct
35 Correct 257 ms 9176 KB Output is correct
36 Correct 217 ms 9700 KB Output is correct
37 Correct 215 ms 9924 KB Output is correct
38 Correct 232 ms 9892 KB Output is correct
39 Correct 204 ms 8968 KB Output is correct
40 Correct 208 ms 8848 KB Output is correct
41 Correct 225 ms 9052 KB Output is correct
42 Correct 194 ms 9016 KB Output is correct
43 Correct 213 ms 8908 KB Output is correct
44 Correct 188 ms 8612 KB Output is correct
45 Correct 190 ms 8612 KB Output is correct
46 Correct 205 ms 8588 KB Output is correct
47 Correct 225 ms 8624 KB Output is correct
48 Correct 258 ms 8640 KB Output is correct
49 Correct 199 ms 9200 KB Output is correct
50 Correct 194 ms 9152 KB Output is correct
51 Correct 209 ms 9180 KB Output is correct
52 Correct 199 ms 9148 KB Output is correct
53 Correct 261 ms 9268 KB Output is correct