답안 #352405

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
352405 2021-01-20T17:49:35 Z SeDunion Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
342 ms 18796 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 66;

pair<int,int> a[N];
int ans[N], b[N];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	for (int i = 1 ; i <= n + 1 ; ++ i) {
		cin >> a[i].first; a[i].second = i;
	}
	for (int i = 1 ; i <= n ; ++ i) cin >> b[i];
	sort(a + 1, a + 2 + n); sort(b + 1, b + 1 + n);
	multiset<int> s = {0};
	for (int i = 1 ; i <= n ; ++ i) {
		s.insert(a[i + 1].first - b[i]);
	}
	for (int i = 1 ; i - 1 <= n ; ++ i) {
		ans[a[i].second] =*s.rbegin();
		if (i <= n) {
			s.erase(s.find(a[i + 1].first - b[i]));
			s.insert(a[i].first - b[i]);
		}
	}
	for (int i = 1 ; i <= n + 1 ; ++ i) cout << ans[i] << " ";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 2 ms 492 KB Output is correct
18 Correct 2 ms 492 KB Output is correct
19 Correct 2 ms 492 KB Output is correct
20 Correct 2 ms 492 KB Output is correct
21 Correct 2 ms 620 KB Output is correct
22 Correct 2 ms 492 KB Output is correct
23 Correct 2 ms 492 KB Output is correct
24 Correct 2 ms 492 KB Output is correct
25 Correct 2 ms 492 KB Output is correct
26 Correct 2 ms 492 KB Output is correct
27 Correct 2 ms 492 KB Output is correct
28 Correct 3 ms 492 KB Output is correct
29 Correct 2 ms 492 KB Output is correct
30 Correct 2 ms 492 KB Output is correct
31 Correct 2 ms 492 KB Output is correct
32 Correct 2 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 2 ms 492 KB Output is correct
18 Correct 2 ms 492 KB Output is correct
19 Correct 2 ms 492 KB Output is correct
20 Correct 2 ms 492 KB Output is correct
21 Correct 2 ms 620 KB Output is correct
22 Correct 2 ms 492 KB Output is correct
23 Correct 2 ms 492 KB Output is correct
24 Correct 2 ms 492 KB Output is correct
25 Correct 2 ms 492 KB Output is correct
26 Correct 2 ms 492 KB Output is correct
27 Correct 2 ms 492 KB Output is correct
28 Correct 3 ms 492 KB Output is correct
29 Correct 2 ms 492 KB Output is correct
30 Correct 2 ms 492 KB Output is correct
31 Correct 2 ms 492 KB Output is correct
32 Correct 2 ms 492 KB Output is correct
33 Correct 234 ms 17516 KB Output is correct
34 Correct 241 ms 18284 KB Output is correct
35 Correct 222 ms 17700 KB Output is correct
36 Correct 233 ms 18280 KB Output is correct
37 Correct 242 ms 18796 KB Output is correct
38 Correct 226 ms 18540 KB Output is correct
39 Correct 312 ms 17516 KB Output is correct
40 Correct 313 ms 17388 KB Output is correct
41 Correct 324 ms 17644 KB Output is correct
42 Correct 308 ms 17644 KB Output is correct
43 Correct 309 ms 17516 KB Output is correct
44 Correct 203 ms 16876 KB Output is correct
45 Correct 205 ms 17004 KB Output is correct
46 Correct 200 ms 16876 KB Output is correct
47 Correct 179 ms 17388 KB Output is correct
48 Correct 179 ms 17388 KB Output is correct
49 Correct 342 ms 18028 KB Output is correct
50 Correct 328 ms 18028 KB Output is correct
51 Correct 324 ms 17956 KB Output is correct
52 Correct 324 ms 17900 KB Output is correct
53 Correct 320 ms 17900 KB Output is correct