#include <bits/stdc++.h>
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
using namespace std;
typedef pair < long long, long long > pll;
typedef pair < int, int > pii;
typedef unsigned long long ull;
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;
typedef long long ll;
typedef double db;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e5 + 11;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;
int b[N], n, pref[N], suff[N], ans[N];
pii a[N];
main () {
cin >> n;
forn (i, 1, n + 1) {
cin >> a[i].f;
a[i].s = i;
}
forn (i, 1, n)
cin >> b[i];
sort(a + 1, a + 2 + n);
sort(b + 1, b + 1 + n);
forn (i, 1, n)
pref[i] = max(pref[i - 1], a[i].f - b[i]);
forev (i, n, 1)
suff[i] = max(suff[i + 1], a[i + 1].f - b[i]);
forn (i, 1, n + 1)
ans[a[i].s] = max(pref[i - 1], suff[i]);
forn (i, 1, n + 1)
cout << ans[i] << ' ';
return 0;
}
Compilation message
ho_t1.cpp:44:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main () {
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
380 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
380 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
380 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
380 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
6 ms |
376 KB |
Output is correct |
15 |
Correct |
7 ms |
376 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
7 ms |
376 KB |
Output is correct |
18 |
Correct |
7 ms |
376 KB |
Output is correct |
19 |
Correct |
7 ms |
376 KB |
Output is correct |
20 |
Correct |
8 ms |
376 KB |
Output is correct |
21 |
Correct |
7 ms |
504 KB |
Output is correct |
22 |
Correct |
7 ms |
504 KB |
Output is correct |
23 |
Correct |
7 ms |
376 KB |
Output is correct |
24 |
Correct |
8 ms |
376 KB |
Output is correct |
25 |
Correct |
8 ms |
504 KB |
Output is correct |
26 |
Correct |
7 ms |
376 KB |
Output is correct |
27 |
Correct |
7 ms |
376 KB |
Output is correct |
28 |
Correct |
7 ms |
376 KB |
Output is correct |
29 |
Correct |
7 ms |
376 KB |
Output is correct |
30 |
Correct |
8 ms |
504 KB |
Output is correct |
31 |
Correct |
7 ms |
376 KB |
Output is correct |
32 |
Correct |
7 ms |
380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
380 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
380 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
6 ms |
376 KB |
Output is correct |
15 |
Correct |
7 ms |
376 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
7 ms |
376 KB |
Output is correct |
18 |
Correct |
7 ms |
376 KB |
Output is correct |
19 |
Correct |
7 ms |
376 KB |
Output is correct |
20 |
Correct |
8 ms |
376 KB |
Output is correct |
21 |
Correct |
7 ms |
504 KB |
Output is correct |
22 |
Correct |
7 ms |
504 KB |
Output is correct |
23 |
Correct |
7 ms |
376 KB |
Output is correct |
24 |
Correct |
8 ms |
376 KB |
Output is correct |
25 |
Correct |
8 ms |
504 KB |
Output is correct |
26 |
Correct |
7 ms |
376 KB |
Output is correct |
27 |
Correct |
7 ms |
376 KB |
Output is correct |
28 |
Correct |
7 ms |
376 KB |
Output is correct |
29 |
Correct |
7 ms |
376 KB |
Output is correct |
30 |
Correct |
8 ms |
504 KB |
Output is correct |
31 |
Correct |
7 ms |
376 KB |
Output is correct |
32 |
Correct |
7 ms |
380 KB |
Output is correct |
33 |
Correct |
303 ms |
10960 KB |
Output is correct |
34 |
Correct |
300 ms |
11256 KB |
Output is correct |
35 |
Correct |
304 ms |
11000 KB |
Output is correct |
36 |
Correct |
294 ms |
11384 KB |
Output is correct |
37 |
Correct |
309 ms |
11884 KB |
Output is correct |
38 |
Correct |
309 ms |
11608 KB |
Output is correct |
39 |
Correct |
297 ms |
10616 KB |
Output is correct |
40 |
Correct |
296 ms |
10616 KB |
Output is correct |
41 |
Correct |
306 ms |
10872 KB |
Output is correct |
42 |
Correct |
299 ms |
10616 KB |
Output is correct |
43 |
Correct |
295 ms |
10616 KB |
Output is correct |
44 |
Correct |
288 ms |
10232 KB |
Output is correct |
45 |
Correct |
298 ms |
10232 KB |
Output is correct |
46 |
Correct |
290 ms |
10232 KB |
Output is correct |
47 |
Correct |
295 ms |
10232 KB |
Output is correct |
48 |
Correct |
303 ms |
10364 KB |
Output is correct |
49 |
Correct |
307 ms |
10872 KB |
Output is correct |
50 |
Correct |
303 ms |
10976 KB |
Output is correct |
51 |
Correct |
307 ms |
10916 KB |
Output is correct |
52 |
Correct |
312 ms |
11076 KB |
Output is correct |
53 |
Correct |
298 ms |
10872 KB |
Output is correct |