# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
491429 |
2021-12-02T04:06:30 Z |
Joo |
Gap (APIO16_gap) |
C++17 |
|
57 ms |
1856 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
long long findGap(int T, int N)
{
if(T == 1){
long long arr[N] = {}, l = 0, r = N-1;
for(; l <= r; l++, r--){
if(l == 0) MinMax(0, 1e18, &arr[l], &arr[r]);
else MinMax(arr[l-1]+1, arr[r+1]-1, &arr[l], &arr[r]);
}
long long ans = 0;
for(int i = 0; i < N-1; i++){
ans = max(ans, arr[i+1]-arr[i]);
}
// for(int i = 0; i < N; i++) cout << arr[i] << " \n"[i==N-1];
return ans;
}
if(T == 2){
long long L, R;
MinMax(0, 1e18, &L, &R);
long long sz = (R-L-1)/(N-1), l = L+1, pre = L, ans = 0, cnt = 0;
while(l < R){
long long r = min(R-1, l+sz-1), mn, mx;
if(++cnt == N){
r = R-1;
}
if(l > r) break;
MinMax(l, r, &mn, &mx);
if(mn != -1){
ans = max(ans, mn-pre);
pre = mx;
}
l = r+1;
}
assert(cnt <= N);
ans = max(ans, R-pre);
return ans;
}
//return 0;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
52 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
0 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
0 ms |
200 KB |
Output is correct |
8 |
Correct |
0 ms |
200 KB |
Output is correct |
9 |
Correct |
0 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
11 ms |
676 KB |
Output is correct |
17 |
Correct |
12 ms |
656 KB |
Output is correct |
18 |
Correct |
11 ms |
616 KB |
Output is correct |
19 |
Correct |
9 ms |
680 KB |
Output is correct |
20 |
Correct |
7 ms |
704 KB |
Output is correct |
21 |
Correct |
44 ms |
1816 KB |
Output is correct |
22 |
Correct |
36 ms |
1820 KB |
Output is correct |
23 |
Correct |
38 ms |
1816 KB |
Output is correct |
24 |
Correct |
37 ms |
1852 KB |
Output is correct |
25 |
Correct |
36 ms |
1852 KB |
Output is correct |
26 |
Correct |
38 ms |
1856 KB |
Output is correct |
27 |
Correct |
36 ms |
1820 KB |
Output is correct |
28 |
Correct |
44 ms |
1840 KB |
Output is correct |
29 |
Correct |
36 ms |
1852 KB |
Output is correct |
30 |
Correct |
37 ms |
1728 KB |
Output is correct |
31 |
Correct |
0 ms |
200 KB |
Output is correct |
32 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
0 ms |
200 KB |
Output is correct |
6 |
Correct |
0 ms |
200 KB |
Output is correct |
7 |
Correct |
0 ms |
200 KB |
Output is correct |
8 |
Correct |
0 ms |
200 KB |
Output is correct |
9 |
Correct |
0 ms |
200 KB |
Output is correct |
10 |
Correct |
0 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
200 KB |
Output is correct |
12 |
Correct |
1 ms |
200 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
2 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
13 ms |
456 KB |
Output is correct |
17 |
Correct |
13 ms |
456 KB |
Output is correct |
18 |
Correct |
15 ms |
504 KB |
Output is correct |
19 |
Correct |
13 ms |
508 KB |
Output is correct |
20 |
Correct |
7 ms |
456 KB |
Output is correct |
21 |
Correct |
51 ms |
1052 KB |
Output is correct |
22 |
Correct |
52 ms |
1076 KB |
Output is correct |
23 |
Correct |
52 ms |
1072 KB |
Output is correct |
24 |
Correct |
51 ms |
1072 KB |
Output is correct |
25 |
Correct |
47 ms |
1076 KB |
Output is correct |
26 |
Correct |
51 ms |
1132 KB |
Output is correct |
27 |
Correct |
52 ms |
1036 KB |
Output is correct |
28 |
Correct |
57 ms |
1196 KB |
Output is correct |
29 |
Correct |
52 ms |
1076 KB |
Output is correct |
30 |
Correct |
26 ms |
1060 KB |
Output is correct |
31 |
Correct |
0 ms |
200 KB |
Output is correct |
32 |
Correct |
0 ms |
200 KB |
Output is correct |