답안 #762986

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
762986 2023-06-22T02:06:32 Z vjudge1 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
291 ms 15528 KB
#include <bits/stdc++.h>
using namespace std;
main()
{
	int n; cin >> n;
	vector <int> a(n + 1);
	for(int i = 0; i <= n; i++) cin >> a[i];
	vector <int> a0 = a;
	vector <int> b(n);
	for(int i = 0; i < n; i++) cin >> b[i];
	sort(a.begin(), a.end()); sort(b.begin(), b.end());
	map <int, int> idx;
	for(int i = 0; i <= n; i++) idx[a[i]] = i;
	vector <int> dpl(n + 1), dpr(n + 1);
	for(int i = 1; i <= n; i++)
	{
		dpl[i] = max(0, a[i - 1] - b[i - 1]);
		dpr[i - 1] = max(0, a[i] - b[i - 1]);
	}
	for(int i = 1; i <= n; i++) dpl[i] = max(dpl[i], dpl[i - 1]);
	for(int i = n; i >= 1; i--) dpr[i - 1] = max(dpr[i - 1], dpr[i]);
	for(int i = 0; i <= n; i++)
	{
		if(i != 0) cout << " ";
		int trace = idx[a0[i]];
		cout << max(dpl[trace], dpr[trace]);
	}
}

Compilation message

ho_t1.cpp:3:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    3 | main()
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 3 ms 340 KB Output is correct
33 Correct 223 ms 14488 KB Output is correct
34 Correct 242 ms 15084 KB Output is correct
35 Correct 264 ms 14612 KB Output is correct
36 Correct 232 ms 15016 KB Output is correct
37 Correct 242 ms 15528 KB Output is correct
38 Correct 263 ms 15256 KB Output is correct
39 Correct 233 ms 14332 KB Output is correct
40 Correct 263 ms 14280 KB Output is correct
41 Correct 237 ms 14376 KB Output is correct
42 Correct 248 ms 14372 KB Output is correct
43 Correct 247 ms 14264 KB Output is correct
44 Correct 227 ms 13816 KB Output is correct
45 Correct 229 ms 13980 KB Output is correct
46 Correct 231 ms 13840 KB Output is correct
47 Correct 175 ms 6612 KB Output is correct
48 Correct 187 ms 6616 KB Output is correct
49 Correct 249 ms 14672 KB Output is correct
50 Correct 291 ms 14724 KB Output is correct
51 Correct 262 ms 14908 KB Output is correct
52 Correct 251 ms 14780 KB Output is correct
53 Correct 238 ms 14776 KB Output is correct