# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
849860 |
2023-09-15T13:17:38 Z |
nnin |
Gap (APIO16_gap) |
C++14 |
|
41 ms |
3108 KB |
#include "gap.h"
#define ll long long
#include<bits/stdc++.h>
using namespace std;
long long findGap(int T, int N) {
ll mn, mx, curmn, curmx;
MinMax((ll)0, (ll)1e18, &mn, &mx);
ll ans = 0;
if(T==1) {
while(N>2) {
MinMax(mn+1, mx-1, &curmn, &curmx);
ans = max(ans, max(curmn-mn, mx-curmx));
N -= 2;
mx = curmx;
mn = curmn;
}
ans = max(ans, mx-mn);
} else {
ll gap = ans = (mx-mn-1)/(N-1);
ll rem = (mx-mn-1)%(N-1);
ll last = mn;
for(int i=1;i<N;i++) {
MinMax(last+1, mn+gap+(i<=rem), &curmn, &curmx);
if(curmn!=-1) {
ans = max(ans, curmn-last);
last = curmx;
}
mn += gap+(i<=rem);
}
ans = max(ans, mx-last);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
0 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
0 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
2 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2504 KB |
Output is correct |
16 |
Correct |
7 ms |
2592 KB |
Output is correct |
17 |
Correct |
7 ms |
2584 KB |
Output is correct |
18 |
Correct |
7 ms |
2752 KB |
Output is correct |
19 |
Correct |
8 ms |
2592 KB |
Output is correct |
20 |
Correct |
6 ms |
2572 KB |
Output is correct |
21 |
Correct |
30 ms |
3108 KB |
Output is correct |
22 |
Correct |
28 ms |
2856 KB |
Output is correct |
23 |
Correct |
29 ms |
2872 KB |
Output is correct |
24 |
Correct |
28 ms |
2860 KB |
Output is correct |
25 |
Correct |
25 ms |
2852 KB |
Output is correct |
26 |
Correct |
29 ms |
2848 KB |
Output is correct |
27 |
Correct |
28 ms |
2852 KB |
Output is correct |
28 |
Correct |
28 ms |
2860 KB |
Output is correct |
29 |
Correct |
29 ms |
2760 KB |
Output is correct |
30 |
Correct |
25 ms |
2848 KB |
Output is correct |
31 |
Correct |
1 ms |
2392 KB |
Output is correct |
32 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
0 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
12 ms |
2588 KB |
Output is correct |
17 |
Correct |
10 ms |
2588 KB |
Output is correct |
18 |
Correct |
10 ms |
2592 KB |
Output is correct |
19 |
Correct |
10 ms |
2588 KB |
Output is correct |
20 |
Correct |
5 ms |
2576 KB |
Output is correct |
21 |
Correct |
40 ms |
2856 KB |
Output is correct |
22 |
Correct |
41 ms |
3096 KB |
Output is correct |
23 |
Correct |
41 ms |
2860 KB |
Output is correct |
24 |
Correct |
39 ms |
2860 KB |
Output is correct |
25 |
Correct |
38 ms |
2848 KB |
Output is correct |
26 |
Correct |
40 ms |
2860 KB |
Output is correct |
27 |
Correct |
40 ms |
2860 KB |
Output is correct |
28 |
Correct |
40 ms |
2852 KB |
Output is correct |
29 |
Correct |
40 ms |
2856 KB |
Output is correct |
30 |
Correct |
23 ms |
2864 KB |
Output is correct |
31 |
Correct |
0 ms |
2392 KB |
Output is correct |
32 |
Correct |
0 ms |
2392 KB |
Output is correct |