#include <bits/stdc++.h>
#define ll long long
#define int long long
#define pb push_back
#define F first
#define S second
using namespace std;
const long long N = 2e5+10;
const long long mod = 1e9+7;
const long long inf = 1e18;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
vector<int>a(n+2),b(n+1);
for(int i=1;i<=n+1;i++) cin >> a[i];
for(int i=1;i<=n;i++) cin >> b[i];
sort(b.begin()+1,b.end());
for(int i=1;i<=n+1;i++) {
int res = 0,ptr = 1;
vector<int>V;
V.pb(0);
for(int j=1;j<i;j++) V.pb(a[j]);
for(int j=i+1;j<=n+1;j++) V.pb(a[j]);
sort(V.begin()+1,V.end());
for(int j=1;j<=n;j++) res = max(res,max(0ll,V[j]-b[j]));
cout << res << ' ';
}
return 0;
}
Compilation message
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:33:15: warning: unused variable 'ptr' [-Wunused-variable]
33 | int res = 0,ptr = 1;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
324 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
320 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
324 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
320 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
20 ms |
364 KB |
Output is correct |
15 |
Correct |
69 ms |
404 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
121 ms |
412 KB |
Output is correct |
18 |
Correct |
87 ms |
400 KB |
Output is correct |
19 |
Correct |
90 ms |
412 KB |
Output is correct |
20 |
Correct |
87 ms |
392 KB |
Output is correct |
21 |
Correct |
91 ms |
416 KB |
Output is correct |
22 |
Correct |
85 ms |
340 KB |
Output is correct |
23 |
Correct |
85 ms |
392 KB |
Output is correct |
24 |
Correct |
95 ms |
396 KB |
Output is correct |
25 |
Correct |
133 ms |
412 KB |
Output is correct |
26 |
Correct |
122 ms |
412 KB |
Output is correct |
27 |
Correct |
119 ms |
404 KB |
Output is correct |
28 |
Correct |
135 ms |
396 KB |
Output is correct |
29 |
Correct |
95 ms |
384 KB |
Output is correct |
30 |
Correct |
119 ms |
388 KB |
Output is correct |
31 |
Correct |
139 ms |
408 KB |
Output is correct |
32 |
Correct |
152 ms |
396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
324 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
320 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
20 ms |
364 KB |
Output is correct |
15 |
Correct |
69 ms |
404 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
121 ms |
412 KB |
Output is correct |
18 |
Correct |
87 ms |
400 KB |
Output is correct |
19 |
Correct |
90 ms |
412 KB |
Output is correct |
20 |
Correct |
87 ms |
392 KB |
Output is correct |
21 |
Correct |
91 ms |
416 KB |
Output is correct |
22 |
Correct |
85 ms |
340 KB |
Output is correct |
23 |
Correct |
85 ms |
392 KB |
Output is correct |
24 |
Correct |
95 ms |
396 KB |
Output is correct |
25 |
Correct |
133 ms |
412 KB |
Output is correct |
26 |
Correct |
122 ms |
412 KB |
Output is correct |
27 |
Correct |
119 ms |
404 KB |
Output is correct |
28 |
Correct |
135 ms |
396 KB |
Output is correct |
29 |
Correct |
95 ms |
384 KB |
Output is correct |
30 |
Correct |
119 ms |
388 KB |
Output is correct |
31 |
Correct |
139 ms |
408 KB |
Output is correct |
32 |
Correct |
152 ms |
396 KB |
Output is correct |
33 |
Execution timed out |
1065 ms |
10696 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |