Submission #201347

# Submission time Handle Problem Language Result Execution time Memory
201347 2020-02-10T09:05:48 Z Mamnoon_Siam Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
341 ms 7160 KB
#include  <bits/stdc++.h>
using namespace std;

using ll = long long;
using ii = pair<int, int>;

const int maxn = 2e5 + 5;

int n;
int a[maxn], b[maxn], p[maxn], s[maxn];
int ord[maxn], ans[maxn];

int main(int argc, char const *argv[])
{
#ifdef LOCAL
	freopen("in", "r", stdin);
#endif
	cin >> n;
	for(int i = 1; i <= n+1; i++) {
		cin >> a[i];
	}
	for(int i = 1; i <= n; i++) {
		cin >> b[i];
	}
	iota(ord + 1, ord + 2 + n, 1);
	sort(ord + 1, ord + 2 + n, [](int i, int j){
		return a[i] < a[j];
	});
	sort(a + 1, a + 2 + n);
	sort(b + 1, b + 1 + n);
	for(int i = n+1; i > 1; i--) {
		s[i] = max(s[i+1], a[i] - b[i-1]);
	}
	for(int i = 1; i <= n; i++) {
		p[i] = max(p[i-1], a[i] - b[i]);
	}
	for(int i = 1; i <= n+1; i++) {
		// cout << max(p[i-1], s[i+1]) << ' ';
		ans[ord[i]] = max(p[i-1], s[i+1]);
	}
	for(int i = 1; i <= n+1; i++) cout << ans[i] << ' '; cout << endl;
	return 0;
}

Compilation message

ho_t1.cpp: In function 'int main(int, const char**)':
ho_t1.cpp:41:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(int i = 1; i <= n+1; i++) cout << ans[i] << ' '; cout << endl;
  ^~~
ho_t1.cpp:41:55: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(int i = 1; i <= n+1; i++) cout << ans[i] << ' '; cout << endl;
                                                       ^~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 372 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 248 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 372 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 248 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 6 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 8 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 8 ms 376 KB Output is correct
18 Correct 7 ms 376 KB Output is correct
19 Correct 7 ms 428 KB Output is correct
20 Correct 7 ms 376 KB Output is correct
21 Correct 8 ms 376 KB Output is correct
22 Correct 7 ms 380 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 376 KB Output is correct
26 Correct 8 ms 376 KB Output is correct
27 Correct 8 ms 376 KB Output is correct
28 Correct 8 ms 376 KB Output is correct
29 Correct 7 ms 376 KB Output is correct
30 Correct 7 ms 376 KB Output is correct
31 Correct 8 ms 376 KB Output is correct
32 Correct 7 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 372 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 248 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 6 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 8 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 8 ms 376 KB Output is correct
18 Correct 7 ms 376 KB Output is correct
19 Correct 7 ms 428 KB Output is correct
20 Correct 7 ms 376 KB Output is correct
21 Correct 8 ms 376 KB Output is correct
22 Correct 7 ms 380 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 376 KB Output is correct
26 Correct 8 ms 376 KB Output is correct
27 Correct 8 ms 376 KB Output is correct
28 Correct 8 ms 376 KB Output is correct
29 Correct 7 ms 376 KB Output is correct
30 Correct 7 ms 376 KB Output is correct
31 Correct 8 ms 376 KB Output is correct
32 Correct 7 ms 376 KB Output is correct
33 Correct 321 ms 6524 KB Output is correct
34 Correct 332 ms 6520 KB Output is correct
35 Correct 318 ms 6520 KB Output is correct
36 Correct 328 ms 6872 KB Output is correct
37 Correct 331 ms 7160 KB Output is correct
38 Correct 328 ms 6904 KB Output is correct
39 Correct 327 ms 6056 KB Output is correct
40 Correct 317 ms 6008 KB Output is correct
41 Correct 341 ms 6280 KB Output is correct
42 Correct 322 ms 6136 KB Output is correct
43 Correct 340 ms 6136 KB Output is correct
44 Correct 324 ms 5728 KB Output is correct
45 Correct 330 ms 5752 KB Output is correct
46 Correct 317 ms 5752 KB Output is correct
47 Correct 306 ms 5724 KB Output is correct
48 Correct 305 ms 5624 KB Output is correct
49 Correct 337 ms 6260 KB Output is correct
50 Correct 333 ms 6136 KB Output is correct
51 Correct 327 ms 6520 KB Output is correct
52 Correct 332 ms 6136 KB Output is correct
53 Correct 332 ms 6296 KB Output is correct