Submission #998993

# Submission time Handle Problem Language Result Execution time Memory
998993 2024-06-15T03:34:29 Z Angus_Yeung Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
105 ms 20560 KB
#include <bits/stdc++.h>
#define x first
#define y second
#define pii pair<ll, ll>
typedef long long ll;
const ll MOD = 1000000007LL;
const ll INF = 1e15;
using namespace std;

ll n, b[200010], ans[200010];
pii a[200010];
priority_queue<pii> q;

int main() {
	cin.tie(0); cout.tie(0);
	ios::sync_with_stdio(0);
	
	cin >> n;
	for (int i = 1; i <= n+1; i++) cin >> a[i].x, a[i].y = i;
	for (int i = 1; i <= n; i++) cin >> b[i];
	
	sort(a+1, a+n+2);
	sort(b+1, b+n+1);
	
	for (int i = 1; i <= n; i++) q.push({max(0LL, a[i+1].x-b[i]), i});
	
	for (int i = 1; i <= n+1; i++) {
		while (!q.empty() && q.top().y > 0 && q.top().y < i) q.pop();
		ans[a[i].y] = q.top().x;
		q.push({max(0LL, a[i].x-b[i]), -i});
	}
	
	for (int i = 1; i <= n+1; i++) {
		if (i-1) cout << ' ';
		cout << ans[i];
	}
	cout << "\n";
	
	return 0;
}
/*



*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2580 KB Output is correct
18 Correct 1 ms 2652 KB Output is correct
19 Correct 2 ms 2904 KB Output is correct
20 Correct 1 ms 2652 KB Output is correct
21 Correct 1 ms 2652 KB Output is correct
22 Correct 1 ms 2652 KB Output is correct
23 Correct 1 ms 2652 KB Output is correct
24 Correct 1 ms 2652 KB Output is correct
25 Correct 1 ms 2652 KB Output is correct
26 Correct 1 ms 2652 KB Output is correct
27 Correct 1 ms 2652 KB Output is correct
28 Correct 1 ms 2648 KB Output is correct
29 Correct 1 ms 2524 KB Output is correct
30 Correct 1 ms 2652 KB Output is correct
31 Correct 1 ms 2652 KB Output is correct
32 Correct 2 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2580 KB Output is correct
18 Correct 1 ms 2652 KB Output is correct
19 Correct 2 ms 2904 KB Output is correct
20 Correct 1 ms 2652 KB Output is correct
21 Correct 1 ms 2652 KB Output is correct
22 Correct 1 ms 2652 KB Output is correct
23 Correct 1 ms 2652 KB Output is correct
24 Correct 1 ms 2652 KB Output is correct
25 Correct 1 ms 2652 KB Output is correct
26 Correct 1 ms 2652 KB Output is correct
27 Correct 1 ms 2652 KB Output is correct
28 Correct 1 ms 2648 KB Output is correct
29 Correct 1 ms 2524 KB Output is correct
30 Correct 1 ms 2652 KB Output is correct
31 Correct 1 ms 2652 KB Output is correct
32 Correct 2 ms 2652 KB Output is correct
33 Correct 74 ms 19912 KB Output is correct
34 Correct 74 ms 19824 KB Output is correct
35 Correct 70 ms 18884 KB Output is correct
36 Correct 71 ms 18628 KB Output is correct
37 Correct 76 ms 18948 KB Output is correct
38 Correct 72 ms 19400 KB Output is correct
39 Correct 98 ms 19656 KB Output is correct
40 Correct 97 ms 19400 KB Output is correct
41 Correct 100 ms 20164 KB Output is correct
42 Correct 104 ms 19656 KB Output is correct
43 Correct 98 ms 18632 KB Output is correct
44 Correct 81 ms 14792 KB Output is correct
45 Correct 77 ms 15560 KB Output is correct
46 Correct 78 ms 16076 KB Output is correct
47 Correct 68 ms 20060 KB Output is correct
48 Correct 70 ms 20560 KB Output is correct
49 Correct 105 ms 19416 KB Output is correct
50 Correct 105 ms 20152 KB Output is correct
51 Correct 99 ms 20420 KB Output is correct
52 Correct 101 ms 19652 KB Output is correct
53 Correct 101 ms 19144 KB Output is correct