#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;
ll INF=LLONG_MAX;
ll b[200222],c[200222];
vll a;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
//freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
int n; cin >> n;
for(int i=0; i<=n; i++){
cin >> c[i];
a.pb(c[i]);
}
for(int i=0; i<n; i++)cin >> b[i];
sort(b,b+n);
sort(a.begin(),a.end());
for(int i=0; i<=n; i++){
auto ptr = find(a.begin(),a.end(),c[i])-a.begin();
ll mx = 0; int up=0;
for(int j=0; j<n; j++){
if(j==ptr){
up=1;
}
mx = max(mx,a[j+up]-b[j]);
}
cout << mx << ' ';
}
cout << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
256 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
256 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
9 ms |
512 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
12 ms |
512 KB |
Output is correct |
18 |
Correct |
9 ms |
512 KB |
Output is correct |
19 |
Correct |
9 ms |
512 KB |
Output is correct |
20 |
Correct |
9 ms |
512 KB |
Output is correct |
21 |
Correct |
10 ms |
512 KB |
Output is correct |
22 |
Correct |
9 ms |
504 KB |
Output is correct |
23 |
Correct |
9 ms |
512 KB |
Output is correct |
24 |
Correct |
10 ms |
512 KB |
Output is correct |
25 |
Correct |
11 ms |
512 KB |
Output is correct |
26 |
Correct |
11 ms |
512 KB |
Output is correct |
27 |
Correct |
11 ms |
512 KB |
Output is correct |
28 |
Correct |
11 ms |
512 KB |
Output is correct |
29 |
Correct |
10 ms |
512 KB |
Output is correct |
30 |
Correct |
11 ms |
512 KB |
Output is correct |
31 |
Correct |
12 ms |
512 KB |
Output is correct |
32 |
Correct |
12 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
256 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
9 ms |
512 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
12 ms |
512 KB |
Output is correct |
18 |
Correct |
9 ms |
512 KB |
Output is correct |
19 |
Correct |
9 ms |
512 KB |
Output is correct |
20 |
Correct |
9 ms |
512 KB |
Output is correct |
21 |
Correct |
10 ms |
512 KB |
Output is correct |
22 |
Correct |
9 ms |
504 KB |
Output is correct |
23 |
Correct |
9 ms |
512 KB |
Output is correct |
24 |
Correct |
10 ms |
512 KB |
Output is correct |
25 |
Correct |
11 ms |
512 KB |
Output is correct |
26 |
Correct |
11 ms |
512 KB |
Output is correct |
27 |
Correct |
11 ms |
512 KB |
Output is correct |
28 |
Correct |
11 ms |
512 KB |
Output is correct |
29 |
Correct |
10 ms |
512 KB |
Output is correct |
30 |
Correct |
11 ms |
512 KB |
Output is correct |
31 |
Correct |
12 ms |
512 KB |
Output is correct |
32 |
Correct |
12 ms |
512 KB |
Output is correct |
33 |
Execution timed out |
1092 ms |
8808 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |