Submission #986775

# Submission time Handle Problem Language Result Execution time Memory
986775 2024-05-21T08:08:28 Z siewjh Gap (APIO16_gap) C++17
89.5342 / 100
46 ms 2232 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll cdiv(ll a, ll b){
	return (a + b - 1) / b;
}
ll findGap(int T, int N){
	if (T == 1){
		vector<ll> vec(N);
		ll lv = 0, rv = 1e18, ans = 0;
		for (int l = 0, r = N - 1; l <= r; l++, r--){
			MinMax(lv, rv, &vec[l], &vec[r]);
			lv = vec[l] + 1; rv = vec[r] - 1;
		}
		for (int i = 1; i < N; i++) ans = max(ans, vec[i] - vec[i - 1]);
		return ans;
	}
	else{
		ll mn, mx; MinMax(0, 1e18, &mn, &mx);
		ll gap = cdiv(mx - mn, N - 1), prv = mn, ans = 0;
		for (int i = 0; i < N - 1; i++){
			ll mnh, mxh; MinMax(min(mn + gap * i + 1, mx), min(mn + gap * (i + 1), mx), &mnh, &mxh);
			if (mnh == -1) continue;
			ans = max(ans, mnh - prv);
			prv = mxh;
		}
		return ans;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 8 ms 632 KB Output is correct
17 Correct 7 ms 644 KB Output is correct
18 Correct 8 ms 628 KB Output is correct
19 Correct 7 ms 636 KB Output is correct
20 Correct 6 ms 616 KB Output is correct
21 Correct 30 ms 1980 KB Output is correct
22 Correct 29 ms 1984 KB Output is correct
23 Correct 29 ms 1976 KB Output is correct
24 Correct 29 ms 1976 KB Output is correct
25 Correct 26 ms 1980 KB Output is correct
26 Correct 33 ms 2232 KB Output is correct
27 Correct 29 ms 1988 KB Output is correct
28 Correct 35 ms 1936 KB Output is correct
29 Correct 29 ms 1984 KB Output is correct
30 Correct 25 ms 1952 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 500 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 10 ms 640 KB Output is correct
17 Correct 10 ms 640 KB Output is correct
18 Correct 10 ms 808 KB Output is correct
19 Correct 10 ms 636 KB Output is correct
20 Partially correct 6 ms 612 KB Partially correct
21 Correct 44 ms 1216 KB Output is correct
22 Correct 41 ms 1460 KB Output is correct
23 Correct 40 ms 1096 KB Output is correct
24 Correct 40 ms 1468 KB Output is correct
25 Correct 40 ms 1188 KB Output is correct
26 Correct 41 ms 1232 KB Output is correct
27 Correct 46 ms 1188 KB Output is correct
28 Correct 43 ms 1464 KB Output is correct
29 Correct 40 ms 1208 KB Output is correct
30 Partially correct 24 ms 1200 KB Partially correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 1 ms 596 KB Output is correct