Submission #1114931

# Submission time Handle Problem Language Result Execution time Memory
1114931 2024-11-19T19:57:39 Z AdamGS Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
83 ms 17100 KB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	vector<ll> ludzie;
	vector<pair<ll, int>> szef;
	
	ll p1;
	
	int n;
	
	cin >> n;
	
	for (int i = 0; n >= i; i++) {
		cin >> p1;
		szef.push_back({p1, i});
	}
	for (int i = 0; n > i; i++) {
		cin >> p1;
		ludzie.push_back(p1);
	}
	sort(ludzie.begin(), ludzie.end());
	sort(szef.begin(), szef.end());
	
	vector<ll> pref(n+2);
	vector<ll> suf(n + 2);
	vector<ll> wynik(n+2);
	
	pref[0] = (ll)0;
	suf[n + 1] = (ll)0;
	for (int i = 1; n >= i; i++) {
		pref[i] = max(pref[i - 1], szef[i - 1].first - ludzie[i - 1]);
		//cout << i << " " << pref[i] << "\n";
	}
	for (int i = n; i > 0; i--) {
		suf[i] = max(suf[i + 1], szef[i].first - ludzie[i - 1]);
		//cout << i << " " << suf[i] << "\n";
	}
	for (int i = 1; n + 1 >= i; i++) {
		wynik[szef[i - 1].second] = max(pref[i - 1], suf[i]);
	}
	for (int i = 0; n >= i; i++) {
		cout << wynik[i] << " " ;
	}
	return 0;
}
# Verdict Execution time Memory 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 588 KB Output is correct
# Verdict Execution time Memory 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 588 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 504 KB Output is correct
15 Correct 1 ms 592 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 760 KB Output is correct
19 Correct 1 ms 592 KB Output is correct
20 Correct 1 ms 592 KB Output is correct
21 Correct 1 ms 592 KB Output is correct
22 Correct 2 ms 592 KB Output is correct
23 Correct 1 ms 760 KB Output is correct
24 Correct 2 ms 336 KB Output is correct
25 Correct 1 ms 592 KB Output is correct
26 Correct 1 ms 592 KB Output is correct
27 Correct 2 ms 592 KB Output is correct
28 Correct 1 ms 592 KB Output is correct
29 Correct 1 ms 472 KB Output is correct
30 Correct 1 ms 592 KB Output is correct
31 Correct 1 ms 592 KB Output is correct
32 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory 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 588 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 504 KB Output is correct
15 Correct 1 ms 592 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 760 KB Output is correct
19 Correct 1 ms 592 KB Output is correct
20 Correct 1 ms 592 KB Output is correct
21 Correct 1 ms 592 KB Output is correct
22 Correct 2 ms 592 KB Output is correct
23 Correct 1 ms 760 KB Output is correct
24 Correct 2 ms 336 KB Output is correct
25 Correct 1 ms 592 KB Output is correct
26 Correct 1 ms 592 KB Output is correct
27 Correct 2 ms 592 KB Output is correct
28 Correct 1 ms 592 KB Output is correct
29 Correct 1 ms 472 KB Output is correct
30 Correct 1 ms 592 KB Output is correct
31 Correct 1 ms 592 KB Output is correct
32 Correct 2 ms 604 KB Output is correct
33 Correct 73 ms 16044 KB Output is correct
34 Correct 69 ms 17100 KB Output is correct
35 Correct 67 ms 16312 KB Output is correct
36 Correct 70 ms 16568 KB Output is correct
37 Correct 74 ms 15716 KB Output is correct
38 Correct 70 ms 16824 KB Output is correct
39 Correct 73 ms 15800 KB Output is correct
40 Correct 74 ms 15808 KB Output is correct
41 Correct 78 ms 16056 KB Output is correct
42 Correct 72 ms 16008 KB Output is correct
43 Correct 72 ms 15976 KB Output is correct
44 Correct 79 ms 15800 KB Output is correct
45 Correct 76 ms 15032 KB Output is correct
46 Correct 74 ms 13880 KB Output is correct
47 Correct 79 ms 16100 KB Output is correct
48 Correct 69 ms 15556 KB Output is correct
49 Correct 71 ms 16188 KB Output is correct
50 Correct 78 ms 15540 KB Output is correct
51 Correct 83 ms 16312 KB Output is correct
52 Correct 77 ms 15544 KB Output is correct
53 Correct 72 ms 16324 KB Output is correct