답안 #1115044

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1115044 2024-11-19T23:04:35 Z AdamGS Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
199 ms 19012 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
	ll n;
	cin >> n;
	vector <ll> pracownicy(n);
	vector <ll> krawaty(n+1);
	vector <ll> pre(n);
	vector <ll> suf(n);
	unordered_map <ll, ll> wyniki;
	for(int i = 0; i < n+1; i++){
		cin >> krawaty[i];
	}
	for(int i = 0; i < n; i++){
		cin >> pracownicy[i];
	}
	vector<ll> zapasowa = krawaty;
	sort(pracownicy.begin(), pracownicy.end());
	sort(krawaty.begin(), krawaty.end());
	pre[0] = max(krawaty[0] - pracownicy[0], 0ll);
	for(ll i = 1; i < n; i++){
		pre[i] = max(pre[i-1], krawaty[i] - pracownicy[i]);
	}

	suf[n - 1] = max(krawaty[n]-pracownicy[n-1], 0ll);
	for(ll i = n-2; i >= 0; i--){
		suf[i] = max(suf[i+1],krawaty[i+1]-pracownicy[i]);
	}

	wyniki[krawaty[0]] = suf[0];
	for(ll i = 1; i < n; i++){
		wyniki[krawaty[i]] = max(suf[i], pre[i-1]);
	}
	wyniki[krawaty[n]] = pre[n-1];
	
	for(ll i = 0; i < n+1; i++){
		cout << wyniki[zapasowa[i]] << " ";
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 2 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 2 ms 592 KB Output is correct
18 Correct 2 ms 336 KB Output is correct
19 Correct 3 ms 336 KB Output is correct
20 Correct 3 ms 336 KB Output is correct
21 Correct 3 ms 336 KB Output is correct
22 Correct 2 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 2 ms 336 KB Output is correct
25 Correct 3 ms 592 KB Output is correct
26 Correct 2 ms 592 KB Output is correct
27 Correct 2 ms 592 KB Output is correct
28 Correct 2 ms 592 KB Output is correct
29 Correct 2 ms 472 KB Output is correct
30 Correct 3 ms 760 KB Output is correct
31 Correct 2 ms 592 KB Output is correct
32 Correct 2 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 2 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 2 ms 592 KB Output is correct
18 Correct 2 ms 336 KB Output is correct
19 Correct 3 ms 336 KB Output is correct
20 Correct 3 ms 336 KB Output is correct
21 Correct 3 ms 336 KB Output is correct
22 Correct 2 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 2 ms 336 KB Output is correct
25 Correct 3 ms 592 KB Output is correct
26 Correct 2 ms 592 KB Output is correct
27 Correct 2 ms 592 KB Output is correct
28 Correct 2 ms 592 KB Output is correct
29 Correct 2 ms 472 KB Output is correct
30 Correct 3 ms 760 KB Output is correct
31 Correct 2 ms 592 KB Output is correct
32 Correct 2 ms 592 KB Output is correct
33 Correct 185 ms 18036 KB Output is correct
34 Correct 185 ms 18544 KB Output is correct
35 Correct 183 ms 18300 KB Output is correct
36 Correct 186 ms 18560 KB Output is correct
37 Correct 181 ms 19012 KB Output is correct
38 Correct 199 ms 18936 KB Output is correct
39 Correct 183 ms 18036 KB Output is correct
40 Correct 179 ms 17812 KB Output is correct
41 Correct 174 ms 18128 KB Output is correct
42 Correct 185 ms 18036 KB Output is correct
43 Correct 181 ms 17780 KB Output is correct
44 Correct 181 ms 17452 KB Output is correct
45 Correct 179 ms 17488 KB Output is correct
46 Correct 174 ms 17456 KB Output is correct
47 Correct 140 ms 10148 KB Output is correct
48 Correct 133 ms 10148 KB Output is correct
49 Correct 192 ms 18292 KB Output is correct
50 Correct 181 ms 18292 KB Output is correct
51 Correct 174 ms 18300 KB Output is correct
52 Correct 174 ms 18288 KB Output is correct
53 Correct 178 ms 18412 KB Output is correct