#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN (1000005)
int main() {
ios_base::sync_with_stdio(false);cin.tie(0);
ll N;
ll sum = 0;
ll maximum = 0;
cin>>N;
pair<ll,ll> A[N + 1];
ll z[N + 1];
ll B[N];
vector<pair<ll,ll>> v;
for(ll i = 0;i < (N + 1);i++){
ll a;
cin>>a;
z[i] = a;
A[i].first = a;
A[i].second = i;
}
for(ll i = 0;i < N;i++){
cin>>B[i];
}
sort(A,A + (N + 1));
sort(B,B + N);
multiset<ll> s;
for(ll i = 1;i < (N + 1);i++){
s.insert(max(A[i].first - B[i - 1],0ll));
}
for(ll i = 0;i < (N + 1);i++){
if(i == 0){
v.push_back(make_pair(A[i].second,*prev(s.end())));
}else if(i == N){
s.erase(s.find(max(A[i].first - B[i - 1],0ll)));
s.insert(max(A[i - 1].first - B[i - 1],0ll));
v.push_back(make_pair(A[i].second,*prev(s.end())));
}else{
s.erase(s.find(max(A[i].first - B[i - 1],0ll)));
s.insert(max(A[i - 1].first - B[i - 1],0ll));
v.push_back(make_pair(A[i].second,*prev(s.end())));
s.insert(max(A[i].first - B[i],0ll));
}
}
sort(v.begin(),v.end());
for(ll i = 0;i < v.size();i++){
cout<<v[i].second<<" ";
}
cout<<'\n';
}
Compilation message
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:47:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | for(ll i = 0;i < v.size();i++){
| ~~^~~~~~~~~~
ho_t1.cpp:8:6: warning: unused variable 'sum' [-Wunused-variable]
8 | ll sum = 0;
| ^~~
ho_t1.cpp:9:6: warning: unused variable 'maximum' [-Wunused-variable]
9 | ll maximum = 0;
| ^~~~~~~
ho_t1.cpp:12:6: warning: variable 'z' set but not used [-Wunused-but-set-variable]
12 | ll z[N + 1];
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
2 ms |
460 KB |
Output is correct |
15 |
Correct |
2 ms |
456 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
2 ms |
588 KB |
Output is correct |
18 |
Correct |
2 ms |
460 KB |
Output is correct |
19 |
Correct |
2 ms |
460 KB |
Output is correct |
20 |
Correct |
2 ms |
468 KB |
Output is correct |
21 |
Correct |
2 ms |
588 KB |
Output is correct |
22 |
Correct |
2 ms |
460 KB |
Output is correct |
23 |
Correct |
2 ms |
460 KB |
Output is correct |
24 |
Correct |
2 ms |
588 KB |
Output is correct |
25 |
Correct |
2 ms |
588 KB |
Output is correct |
26 |
Correct |
2 ms |
572 KB |
Output is correct |
27 |
Correct |
2 ms |
588 KB |
Output is correct |
28 |
Correct |
2 ms |
588 KB |
Output is correct |
29 |
Correct |
2 ms |
460 KB |
Output is correct |
30 |
Correct |
2 ms |
588 KB |
Output is correct |
31 |
Correct |
2 ms |
588 KB |
Output is correct |
32 |
Correct |
2 ms |
588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
2 ms |
460 KB |
Output is correct |
15 |
Correct |
2 ms |
456 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
2 ms |
588 KB |
Output is correct |
18 |
Correct |
2 ms |
460 KB |
Output is correct |
19 |
Correct |
2 ms |
460 KB |
Output is correct |
20 |
Correct |
2 ms |
468 KB |
Output is correct |
21 |
Correct |
2 ms |
588 KB |
Output is correct |
22 |
Correct |
2 ms |
460 KB |
Output is correct |
23 |
Correct |
2 ms |
460 KB |
Output is correct |
24 |
Correct |
2 ms |
588 KB |
Output is correct |
25 |
Correct |
2 ms |
588 KB |
Output is correct |
26 |
Correct |
2 ms |
572 KB |
Output is correct |
27 |
Correct |
2 ms |
588 KB |
Output is correct |
28 |
Correct |
2 ms |
588 KB |
Output is correct |
29 |
Correct |
2 ms |
460 KB |
Output is correct |
30 |
Correct |
2 ms |
588 KB |
Output is correct |
31 |
Correct |
2 ms |
588 KB |
Output is correct |
32 |
Correct |
2 ms |
588 KB |
Output is correct |
33 |
Correct |
298 ms |
32316 KB |
Output is correct |
34 |
Correct |
294 ms |
33684 KB |
Output is correct |
35 |
Correct |
271 ms |
32552 KB |
Output is correct |
36 |
Correct |
290 ms |
33188 KB |
Output is correct |
37 |
Correct |
312 ms |
34148 KB |
Output is correct |
38 |
Correct |
273 ms |
33836 KB |
Output is correct |
39 |
Correct |
344 ms |
32704 KB |
Output is correct |
40 |
Correct |
369 ms |
32468 KB |
Output is correct |
41 |
Correct |
381 ms |
32880 KB |
Output is correct |
42 |
Correct |
344 ms |
32688 KB |
Output is correct |
43 |
Correct |
362 ms |
32424 KB |
Output is correct |
44 |
Correct |
262 ms |
31664 KB |
Output is correct |
45 |
Correct |
250 ms |
31876 KB |
Output is correct |
46 |
Correct |
262 ms |
31688 KB |
Output is correct |
47 |
Correct |
238 ms |
32872 KB |
Output is correct |
48 |
Correct |
254 ms |
32916 KB |
Output is correct |
49 |
Correct |
380 ms |
33460 KB |
Output is correct |
50 |
Correct |
370 ms |
33624 KB |
Output is correct |
51 |
Correct |
358 ms |
33528 KB |
Output is correct |
52 |
Correct |
350 ms |
33448 KB |
Output is correct |
53 |
Correct |
387 ms |
33476 KB |
Output is correct |