Submission #906277

# Submission time Handle Problem Language Result Execution time Memory
906277 2024-01-13T22:41:24 Z OAleksa Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
89 ms 14088 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  //cin >> tt;
  while (tt--) {
  	int n;
  	cin >> n;
  	vector<pair<int, int>> a(n + 1);
  	vector<int> b(n);
  	for (int i = 0;i < n + 1;i++)
  		cin >> a[i].f, a[i].s = i;
  	for (int i = 0;i < n;i++)
  		cin >> b[i];
  	sort(a.begin(), a.end());
  	sort(b.begin(), b.end());
  	vector<int> s(n + 2);
  	s[n] = max(a[n].f - b[n - 1], 0ll);
  	for (int i = n - 1;i >= 1;i--)
  		s[i] = max(s[i + 1], max(a[i].f - b[i - 1], 0ll));
  	vector<int> ans(n + 1);
  	int mx = 0;
  	for (int i = 0;i < n + 1;i++) {
  		ans[a[i].s] = max(mx, s[i + 1]);
  		if (i < n)
  			mx = max(mx, max(a[i].f - b[i], 0ll));
  	}
  	for (int i = 0;i < n + 1;i++)
  		cout << ans[i] << ' ';
	}
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 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 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 464 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 2 ms 604 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 2 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 524 KB Output is correct
30 Correct 1 ms 600 KB Output is correct
31 Correct 1 ms 528 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 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 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 464 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 2 ms 604 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 2 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 524 KB Output is correct
30 Correct 1 ms 600 KB Output is correct
31 Correct 1 ms 528 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 76 ms 12960 KB Output is correct
34 Correct 75 ms 13432 KB Output is correct
35 Correct 71 ms 13140 KB Output is correct
36 Correct 76 ms 13552 KB Output is correct
37 Correct 75 ms 14088 KB Output is correct
38 Correct 74 ms 13760 KB Output is correct
39 Correct 75 ms 13136 KB Output is correct
40 Correct 79 ms 12824 KB Output is correct
41 Correct 72 ms 12852 KB Output is correct
42 Correct 79 ms 13096 KB Output is correct
43 Correct 75 ms 12744 KB Output is correct
44 Correct 71 ms 12372 KB Output is correct
45 Correct 70 ms 12372 KB Output is correct
46 Correct 89 ms 12436 KB Output is correct
47 Correct 66 ms 12628 KB Output is correct
48 Correct 68 ms 12628 KB Output is correct
49 Correct 75 ms 13116 KB Output is correct
50 Correct 74 ms 13140 KB Output is correct
51 Correct 75 ms 13332 KB Output is correct
52 Correct 88 ms 13140 KB Output is correct
53 Correct 82 ms 13140 KB Output is correct