Submission #286141

# Submission time Handle Problem Language Result Execution time Memory
286141 2020-08-30T07:18:04 Z reymontada61 Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
639 ms 18680 KB
#include <bits/stdc++.h>
using namespace std;

int n;
const int MXN = 200005;
pair<int, int> arr[MXN];
int brr[MXN];

multiset<int> pairs;

void join(int a, int b) {
	int x = max(0, arr[a].first - brr[b]);
	pairs.insert(x);
}

void unjoin(int a, int b) {
	int x = max(0, arr[a].first - brr[b]);
	pairs.erase(pairs.lower_bound(x));
}

int score() {
	return *(--pairs.end());
}

signed main() {

	cin >> n;
	for (int i=1; i<=n+1; i++) {
		cin >> arr[i].first; 
		arr[i].second = i;
	}
	for (int i=1; i<=n; i++) {
		cin >> brr[i];
	}
	
	sort(arr+1, arr+n+2);
	sort(brr+1, brr+n+1);
	
	for (int i=1; i<=n; i++) {
		join(i+1, i);
	}
	
	vector<int> ans(n+2);
	
	ans[arr[1].second] = score();
	for (int i=1; i<=n; i++) {
		unjoin(i+1, i);
		join(i, i);
		ans[arr[i+1].second] = score();
	}
	
	for (int i=1; i<=n+1; i++) cout << ans[i] << ' '; cout << endl;

}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:52:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   52 |  for (int i=1; i<=n+1; i++) cout << ans[i] << ' '; cout << endl;
      |  ^~~
ho_t1.cpp:52:52: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   52 |  for (int i=1; i<=n+1; i++) cout << ans[i] << ' '; cout << endl;
      |                                                    ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 380 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 380 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 4 ms 512 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 5 ms 512 KB Output is correct
18 Correct 5 ms 512 KB Output is correct
19 Correct 4 ms 512 KB Output is correct
20 Correct 5 ms 640 KB Output is correct
21 Correct 4 ms 512 KB Output is correct
22 Correct 4 ms 512 KB Output is correct
23 Correct 4 ms 544 KB Output is correct
24 Correct 4 ms 512 KB Output is correct
25 Correct 5 ms 512 KB Output is correct
26 Correct 5 ms 512 KB Output is correct
27 Correct 5 ms 512 KB Output is correct
28 Correct 4 ms 512 KB Output is correct
29 Correct 4 ms 512 KB Output is correct
30 Correct 4 ms 512 KB Output is correct
31 Correct 4 ms 512 KB Output is correct
32 Correct 4 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 380 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 4 ms 512 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 5 ms 512 KB Output is correct
18 Correct 5 ms 512 KB Output is correct
19 Correct 4 ms 512 KB Output is correct
20 Correct 5 ms 640 KB Output is correct
21 Correct 4 ms 512 KB Output is correct
22 Correct 4 ms 512 KB Output is correct
23 Correct 4 ms 544 KB Output is correct
24 Correct 4 ms 512 KB Output is correct
25 Correct 5 ms 512 KB Output is correct
26 Correct 5 ms 512 KB Output is correct
27 Correct 5 ms 512 KB Output is correct
28 Correct 4 ms 512 KB Output is correct
29 Correct 4 ms 512 KB Output is correct
30 Correct 4 ms 512 KB Output is correct
31 Correct 4 ms 512 KB Output is correct
32 Correct 4 ms 512 KB Output is correct
33 Correct 500 ms 17528 KB Output is correct
34 Correct 522 ms 18184 KB Output is correct
35 Correct 486 ms 17644 KB Output is correct
36 Correct 509 ms 18168 KB Output is correct
37 Correct 531 ms 18680 KB Output is correct
38 Correct 515 ms 18664 KB Output is correct
39 Correct 602 ms 17516 KB Output is correct
40 Correct 599 ms 17400 KB Output is correct
41 Correct 605 ms 17656 KB Output is correct
42 Correct 608 ms 17528 KB Output is correct
43 Correct 600 ms 17528 KB Output is correct
44 Correct 450 ms 16888 KB Output is correct
45 Correct 471 ms 17144 KB Output is correct
46 Correct 460 ms 17016 KB Output is correct
47 Correct 477 ms 17356 KB Output is correct
48 Correct 482 ms 17400 KB Output is correct
49 Correct 628 ms 17912 KB Output is correct
50 Correct 627 ms 18032 KB Output is correct
51 Correct 631 ms 18040 KB Output is correct
52 Correct 615 ms 18040 KB Output is correct
53 Correct 639 ms 17912 KB Output is correct