답안 #869225

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
869225 2023-11-03T14:27:10 Z goodspeed0208 Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
236 ms 19536 KB
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<set>
using namespace std;
//想10 實作10 
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<pair<int, int> >a(n+1);
	vector<int> b(n);
	vector<int>ans(n);
	for (int i = 0 ; i < n+1 ; i++) {
		cin >> a[i].first;
		a[i].second = i;
	}
	for (auto &i : b) cin >> i;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	for (int i = 0 ; i < n ; i++) {
		ans[i] = max(a[i+1].first - b[i], 0);
	}
	vector<int>out(n+1);
	multiset<int>st;
	for (auto i : ans) st.insert(i);
	for (int i = 0 ; i < n+1 ; i++) {
		out[a[i].second] = *st.rbegin();
		if (i == n) break;
		st.erase(st.find(ans[i]));
		ans[i] = max(a[i].first - b[i], 0);
		st.insert(ans[i]);
	} 
	for (int i = 0 ; i < n+1 ; i++) {
		cout << out[i] << " ";
	}
	cout << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 137 ms 14648 KB Output is correct
34 Correct 155 ms 19032 KB Output is correct
35 Correct 137 ms 18260 KB Output is correct
36 Correct 146 ms 18956 KB Output is correct
37 Correct 144 ms 19536 KB Output is correct
38 Correct 144 ms 19284 KB Output is correct
39 Correct 188 ms 18184 KB Output is correct
40 Correct 185 ms 18004 KB Output is correct
41 Correct 198 ms 18516 KB Output is correct
42 Correct 190 ms 18256 KB Output is correct
43 Correct 179 ms 18128 KB Output is correct
44 Correct 129 ms 17572 KB Output is correct
45 Correct 133 ms 17792 KB Output is correct
46 Correct 128 ms 17488 KB Output is correct
47 Correct 126 ms 18032 KB Output is correct
48 Correct 135 ms 18004 KB Output is correct
49 Correct 194 ms 18768 KB Output is correct
50 Correct 189 ms 18664 KB Output is correct
51 Correct 189 ms 18772 KB Output is correct
52 Correct 236 ms 18676 KB Output is correct
53 Correct 193 ms 18656 KB Output is correct