Submission #917835

# Submission time Handle Problem Language Result Execution time Memory
917835 2024-01-29T01:38:47 Z oblantis Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
169 ms 18772 KB
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int inf = 1e9;
const int mod = 1e9+7;
const int maxn = 2e5 + 1;

void solve() {
	int n;
	cin >> n;
	pii a[n + 1];
	int out[n + 1], b[n];
	for(int i = 0; i <= n; i++){
		cin >> a[i].ff;
		a[i].ss = i;
	}
	multiset<int> s;
	sort(a, a + n + 1);
	for(int i = 0; i < n; i++){
		cin >> b[i];
	}
	sort(b, b + n);
	for(int i = 0; i < n; i++)s.insert(a[i].ff - b[i]);
	for(int i = n; i >= 0; i--){
		out[a[i].ss] = *s.rbegin();
		if(!i)continue;
		s.erase(a[i - 1].ff - b[i - 1]);
		s.insert(a[i].ff - b[i - 1]);
	}
	for(auto i : out)cout << max(0, i) << ' ';
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int times = 1;
	//cin >> times;
	for(int i = 1; i <= times; i++) {
		solve();
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 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 0 ms 600 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 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 0 ms 600 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 2 ms 600 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 600 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 1 ms 516 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 1 ms 604 KB Output is correct
32 Correct 2 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 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 0 ms 600 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 2 ms 600 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 600 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 1 ms 516 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 1 ms 604 KB Output is correct
32 Correct 2 ms 600 KB Output is correct
33 Correct 149 ms 17332 KB Output is correct
34 Correct 157 ms 18256 KB Output is correct
35 Correct 145 ms 17628 KB Output is correct
36 Correct 152 ms 18164 KB Output is correct
37 Correct 159 ms 18772 KB Output is correct
38 Correct 169 ms 18516 KB Output is correct
39 Correct 152 ms 17484 KB Output is correct
40 Correct 152 ms 17232 KB Output is correct
41 Correct 152 ms 18004 KB Output is correct
42 Correct 156 ms 17488 KB Output is correct
43 Correct 148 ms 17236 KB Output is correct
44 Correct 133 ms 16816 KB Output is correct
45 Correct 129 ms 16976 KB Output is correct
46 Correct 143 ms 16796 KB Output is correct
47 Correct 99 ms 17236 KB Output is correct
48 Correct 101 ms 17260 KB Output is correct
49 Correct 159 ms 18016 KB Output is correct
50 Correct 156 ms 18004 KB Output is correct
51 Correct 152 ms 18012 KB Output is correct
52 Correct 152 ms 17856 KB Output is correct
53 Correct 156 ms 17768 KB Output is correct