# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
244847 | 2020-07-05T07:22:50 Z | maximath_1 | Just Long Neckties (JOI20_ho_t1) | C++11 | 185 ms | 7032 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long int n = 0; vector<int> a, b, id, pos, pref, suff; bool cmp(int x, int y){ return a[x] < a[y]; } int main(){ scanf("%d", &n); a.resize(n + 1); id.resize(n + 1); pos.resize(n + 1); b.resize(n); for(int i = 0; i <= n; i ++){ scanf("%d", &a[i]); id[i] = i; } for(int i = 0; i < n; i ++) scanf("%d", &b[i]); sort(id.begin(), id.end(), cmp); sort(a.begin(), a.end()); for(int i = 0; i <= n; i ++) pos[id[i]] = i; sort(b.begin(), b.end()); pref.assign(n + 1, 0); suff.assign(n + 1, 0); for(int i = 1; i <= n; i ++) pref[i] = max(pref[i - 1], a[i - 1] - b[i - 1]); for(int i = n - 1; i >= 0; i --) suff[i] = max(suff[i + 1], a[i + 1] - b[i]); for(int i = 0; i <= n; i ++) printf("%d%c", max(pref[pos[i]], suff[pos[i]]), i == n ? '\n' : ' '); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 256 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 256 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 | 256 KB | Output is correct |
11 | Correct | 4 ms | 256 KB | Output is correct |
12 | Correct | 4 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 256 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 256 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 | 256 KB | Output is correct |
11 | Correct | 4 ms | 256 KB | Output is correct |
12 | Correct | 4 ms | 256 KB | Output is correct |
13 | Correct | 5 ms | 256 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 256 KB | Output is correct |
17 | Correct | 6 ms | 384 KB | Output is correct |
18 | Correct | 6 ms | 384 KB | Output is correct |
19 | Correct | 7 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
21 | Correct | 6 ms | 384 KB | Output is correct |
22 | Correct | 6 ms | 384 KB | Output is correct |
23 | Correct | 6 ms | 384 KB | Output is correct |
24 | Correct | 6 ms | 384 KB | Output is correct |
25 | Correct | 6 ms | 384 KB | Output is correct |
26 | Correct | 6 ms | 384 KB | Output is correct |
27 | Correct | 6 ms | 384 KB | Output is correct |
28 | Correct | 6 ms | 384 KB | Output is correct |
29 | Correct | 6 ms | 384 KB | Output is correct |
30 | Correct | 6 ms | 384 KB | Output is correct |
31 | Correct | 6 ms | 384 KB | Output is correct |
32 | Correct | 6 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 256 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 256 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 | 256 KB | Output is correct |
11 | Correct | 4 ms | 256 KB | Output is correct |
12 | Correct | 4 ms | 256 KB | Output is correct |
13 | Correct | 5 ms | 256 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 256 KB | Output is correct |
17 | Correct | 6 ms | 384 KB | Output is correct |
18 | Correct | 6 ms | 384 KB | Output is correct |
19 | Correct | 7 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
21 | Correct | 6 ms | 384 KB | Output is correct |
22 | Correct | 6 ms | 384 KB | Output is correct |
23 | Correct | 6 ms | 384 KB | Output is correct |
24 | Correct | 6 ms | 384 KB | Output is correct |
25 | Correct | 6 ms | 384 KB | Output is correct |
26 | Correct | 6 ms | 384 KB | Output is correct |
27 | Correct | 6 ms | 384 KB | Output is correct |
28 | Correct | 6 ms | 384 KB | Output is correct |
29 | Correct | 6 ms | 384 KB | Output is correct |
30 | Correct | 6 ms | 384 KB | Output is correct |
31 | Correct | 6 ms | 384 KB | Output is correct |
32 | Correct | 6 ms | 384 KB | Output is correct |
33 | Correct | 169 ms | 6368 KB | Output is correct |
34 | Correct | 175 ms | 6776 KB | Output is correct |
35 | Correct | 170 ms | 6392 KB | Output is correct |
36 | Correct | 173 ms | 6776 KB | Output is correct |
37 | Correct | 180 ms | 7032 KB | Output is correct |
38 | Correct | 177 ms | 6904 KB | Output is correct |
39 | Correct | 173 ms | 6008 KB | Output is correct |
40 | Correct | 170 ms | 6008 KB | Output is correct |
41 | Correct | 184 ms | 6140 KB | Output is correct |
42 | Correct | 174 ms | 6136 KB | Output is correct |
43 | Correct | 171 ms | 6012 KB | Output is correct |
44 | Correct | 167 ms | 5752 KB | Output is correct |
45 | Correct | 172 ms | 5880 KB | Output is correct |
46 | Correct | 171 ms | 5836 KB | Output is correct |
47 | Correct | 135 ms | 5624 KB | Output is correct |
48 | Correct | 132 ms | 5624 KB | Output is correct |
49 | Correct | 175 ms | 6264 KB | Output is correct |
50 | Correct | 179 ms | 6264 KB | Output is correct |
51 | Correct | 178 ms | 6240 KB | Output is correct |
52 | Correct | 176 ms | 6264 KB | Output is correct |
53 | Correct | 185 ms | 6392 KB | Output is correct |