# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
770631 |
2023-07-01T14:37:09 Z |
Enchom |
Gap (APIO16_gap) |
C++14 |
|
40 ms |
1908 KB |
#include <iostream>
#include <stdio.h>
#include <vector>
#include "gap.h"
using namespace std;
typedef long long llong;
const llong MAXVAL = 1000000000000000000LL;
llong solveSmall(int N)
{
llong minVal, maxVal;
llong L = 0, R = MAXVAL;
int pL = 0, pR = N - 1;
vector<llong> nums(N);
while(pL <= pR)
{
MinMax(L, R, &minVal, &maxVal);
nums[pL] = minVal;
nums[pR] = maxVal;
pL++;
pR--;
L = minVal + 1;
R = maxVal - 1;
}
llong ans = 0;
for (int i = 1; i < nums.size(); i++)
{
ans = max(ans, nums[i] - nums[i - 1]);
}
return ans;
}
llong solveBig(int N)
{
llong minVal, maxVal;
llong curVal, endVal;
llong bestGap = 0;
MinMax(0, MAXVAL, &curVal, &endVal);
llong curGap = (endVal - curVal) / (N - 1);
if ( (endVal - curVal) % (N - 1) != 0 )
curGap++;
curGap--;
bestGap = curGap;
while(curVal != endVal)
{
MinMax(curVal + 1, curVal + curGap, &minVal, &maxVal);
if (minVal == -1)
{
bestGap = max(bestGap, curGap);
curGap = curGap * 2 + 2;
}
else
{
bestGap = max(bestGap, minVal - curVal);
curGap = bestGap;
curVal = maxVal;
}
}
return bestGap;
}
llong findGap(int T, int N)
{
if (T == 1)
return solveSmall(N);
else
return solveBig(N);
}
/*
int main()
{
}
*/
Compilation message
gap.cpp: In function 'llong solveSmall(int)':
gap.cpp:31:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | for (int i = 1; i < nums.size(); i++)
| ~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
9 ms |
716 KB |
Output is correct |
17 |
Correct |
8 ms |
720 KB |
Output is correct |
18 |
Correct |
8 ms |
604 KB |
Output is correct |
19 |
Correct |
8 ms |
708 KB |
Output is correct |
20 |
Correct |
6 ms |
616 KB |
Output is correct |
21 |
Correct |
36 ms |
1820 KB |
Output is correct |
22 |
Correct |
31 ms |
1864 KB |
Output is correct |
23 |
Correct |
31 ms |
1820 KB |
Output is correct |
24 |
Correct |
31 ms |
1872 KB |
Output is correct |
25 |
Correct |
28 ms |
1872 KB |
Output is correct |
26 |
Correct |
30 ms |
1872 KB |
Output is correct |
27 |
Correct |
30 ms |
1828 KB |
Output is correct |
28 |
Correct |
32 ms |
1908 KB |
Output is correct |
29 |
Correct |
31 ms |
1836 KB |
Output is correct |
30 |
Correct |
26 ms |
1872 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
5 ms |
428 KB |
Output is correct |
17 |
Correct |
5 ms |
464 KB |
Output is correct |
18 |
Correct |
5 ms |
464 KB |
Output is correct |
19 |
Correct |
5 ms |
552 KB |
Output is correct |
20 |
Correct |
3 ms |
464 KB |
Output is correct |
21 |
Correct |
18 ms |
1068 KB |
Output is correct |
22 |
Correct |
19 ms |
1068 KB |
Output is correct |
23 |
Correct |
25 ms |
1080 KB |
Output is correct |
24 |
Correct |
19 ms |
1080 KB |
Output is correct |
25 |
Correct |
40 ms |
976 KB |
Output is correct |
26 |
Correct |
19 ms |
1068 KB |
Output is correct |
27 |
Correct |
19 ms |
1188 KB |
Output is correct |
28 |
Correct |
26 ms |
1024 KB |
Output is correct |
29 |
Correct |
25 ms |
1056 KB |
Output is correct |
30 |
Correct |
11 ms |
976 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
1 ms |
208 KB |
Output is correct |