답안 #674843

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
674843 2022-12-26T10:33:26 Z sudheerays123 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
272 ms 21792 KB
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
const ll N = 100+5 , INF = 1e18 , MOD = 1e9+7;

void solve(){

	ll n;
	cin >> n;

	vector<pair<ll,ll>> a(n+5);
	vector<ll> b(n+5);

	for(ll i = 1; i <= n+1; i++){
		cin >> a[i].first;
		a[i].second = i;
	}
	for(ll i = 1; i <= n; i++) cin >> b[i];

	sort(a.begin()+1,a.begin()+n+2);
	sort(b.begin()+1,b.begin()+n+1);

	vector<ll> ans(n+5);

	multiset<ll> s;
	for(ll i = 2; i <= n+1; i++) s.insert(a[i].first-b[i-1]);

	auto it = s.end();
	it--;
	ans[a[1].second] = (*(it));

	for(ll i = 2; i <= n+1; i++){
		s.erase(s.find(a[i].first-b[i-1]));
		s.insert(a[i-1].first-b[i-1]);

		auto it = s.end();
		it--;
		ans[a[i].second] = (*(it));
	}

	for(ll i = 1; i <= n+1; i++) cout << ans[i] << " ";
}

int main(){

	fast;

	ll tc = 1;
	// cin >> tc;
	while(tc--) solve();

	return 0;
}
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 1 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 0 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 320 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 460 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 3 ms 468 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 2 ms 464 KB Output is correct
23 Correct 2 ms 460 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 2 ms 456 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 2 ms 456 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 0 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 320 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 460 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 3 ms 468 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 2 ms 464 KB Output is correct
23 Correct 2 ms 460 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 2 ms 456 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 2 ms 456 KB Output is correct
33 Correct 171 ms 20352 KB Output is correct
34 Correct 183 ms 21236 KB Output is correct
35 Correct 180 ms 20564 KB Output is correct
36 Correct 179 ms 21068 KB Output is correct
37 Correct 170 ms 21792 KB Output is correct
38 Correct 178 ms 21440 KB Output is correct
39 Correct 223 ms 20372 KB Output is correct
40 Correct 235 ms 20256 KB Output is correct
41 Correct 245 ms 20576 KB Output is correct
42 Correct 215 ms 20532 KB Output is correct
43 Correct 222 ms 20360 KB Output is correct
44 Correct 171 ms 19736 KB Output is correct
45 Correct 164 ms 19968 KB Output is correct
46 Correct 168 ms 19728 KB Output is correct
47 Correct 152 ms 20396 KB Output is correct
48 Correct 175 ms 20372 KB Output is correct
49 Correct 246 ms 20980 KB Output is correct
50 Correct 225 ms 21100 KB Output is correct
51 Correct 263 ms 20916 KB Output is correct
52 Correct 233 ms 21012 KB Output is correct
53 Correct 272 ms 21040 KB Output is correct