Submission #418042

# Submission time Handle Problem Language Result Execution time Memory
418042 2021-06-04T23:20:18 Z FerThugGato12500 Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
123 ms 13232 KB
#include<bits/stdc++.h>
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define ll long long
using namespace std;
const int lmt = 200005;
struct wer{
	int v, i, otheri;
};
bool operator < (const wer &a, const wer &b){
	return a.v < b.v;
}
wer p[lmt];
int a[lmt];
int ans[lmt];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n; cin>>n;
	forn(i, n+1){
		cin>>p[i].v;
		p[i].i = i;
	}
	forn(i, n) cin>>a[i];
	sort(p, p+n+1);
	sort(a,a+n);
	priority_queue<wer> mqun;
	forn(i, n){
		mqun.push({max(p[i].v-a[i],0),p[i].i,i});
	}
	ans[p[n].i] = mqun.top().v;
	for(int i = n; i>= 0; i--){
		mqun.push({max(p[i+1].v - a[i], 0), p[i].i, -1});
		while(mqun.top().otheri >= i){
			mqun.pop();
		}
		ans[p[i].i] = mqun.top().v;
	}
	forn(i, n+1){
		cout<<ans[i]<<" ";
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 2 ms 460 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 2 ms 460 KB Output is correct
25 Correct 2 ms 456 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 2 ms 460 KB Output is correct
28 Correct 1 ms 460 KB Output is correct
29 Correct 1 ms 460 KB Output is correct
30 Correct 1 ms 460 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 2 ms 460 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 2 ms 460 KB Output is correct
25 Correct 2 ms 456 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 2 ms 460 KB Output is correct
28 Correct 1 ms 460 KB Output is correct
29 Correct 1 ms 460 KB Output is correct
30 Correct 1 ms 460 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
33 Correct 113 ms 12528 KB Output is correct
34 Correct 123 ms 12856 KB Output is correct
35 Correct 115 ms 12596 KB Output is correct
36 Correct 117 ms 12956 KB Output is correct
37 Correct 120 ms 13224 KB Output is correct
38 Correct 118 ms 13232 KB Output is correct
39 Correct 116 ms 12680 KB Output is correct
40 Correct 114 ms 12648 KB Output is correct
41 Correct 114 ms 12724 KB Output is correct
42 Correct 115 ms 12724 KB Output is correct
43 Correct 115 ms 12596 KB Output is correct
44 Correct 111 ms 12632 KB Output is correct
45 Correct 112 ms 12596 KB Output is correct
46 Correct 111 ms 12584 KB Output is correct
47 Correct 99 ms 12704 KB Output is correct
48 Correct 98 ms 12720 KB Output is correct
49 Correct 120 ms 12832 KB Output is correct
50 Correct 116 ms 12756 KB Output is correct
51 Correct 117 ms 12724 KB Output is correct
52 Correct 118 ms 12840 KB Output is correct
53 Correct 118 ms 12852 KB Output is correct