# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
713432 |
2023-03-22T02:29:05 Z |
Vu_CG_Coder |
Gap (APIO16_gap) |
C++14 |
|
56 ms |
2244 KB |
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <bits/stdc++.h>
#include "gap.h"
#define ll long long
using namespace std;
long long sub1(int n)
{
long long l = 0 , r = 1e18;
vector <long long> kq;
for (int i = 1 ; i <= (n + 1)/2 ; i++)
{
ll s , t;
MinMax(l,r,&s,&t);
kq.push_back(s);
kq.push_back(t);
l = (s) + 1;
r = (t) - 1;
}
sort(kq.begin(),kq.end());
long long res = 0;
for (int i = 1 ; i < kq.size() ; i++)
res = max(res,kq[i] - kq[i - 1]);
return res;
}
long long sub2(int n)
{
long long mn , mx , a = 0 , b = 1e18;
MinMax(a,b,&mn,&mx);
long long res = 0;
long long step = (mx - mn + 1 + n)/(n - 1);
long long l = mn , i = mn;
for (i = mn ; i <= mx ; i += step)
{
long long x , y;
MinMax(i + 1,min(i+step,mx),&x,&y);
if (x != -1)
{
res = max(res,x - l);
l = y;
}
}
return res;
}
long long findGap(int t , int n)
{
if (t == 1) return sub1(n);
else return sub2(n);
}
Compilation message
gap.cpp: In function 'long long int sub1(int)':
gap.cpp:28:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | for (int i = 1 ; i < kq.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 |
0 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 |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
0 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 |
11 ms |
848 KB |
Output is correct |
17 |
Correct |
10 ms |
848 KB |
Output is correct |
18 |
Correct |
12 ms |
816 KB |
Output is correct |
19 |
Correct |
10 ms |
848 KB |
Output is correct |
20 |
Correct |
9 ms |
848 KB |
Output is correct |
21 |
Correct |
38 ms |
2196 KB |
Output is correct |
22 |
Correct |
37 ms |
2240 KB |
Output is correct |
23 |
Correct |
39 ms |
2212 KB |
Output is correct |
24 |
Correct |
40 ms |
2244 KB |
Output is correct |
25 |
Correct |
37 ms |
2240 KB |
Output is correct |
26 |
Correct |
40 ms |
2240 KB |
Output is correct |
27 |
Correct |
39 ms |
2148 KB |
Output is correct |
28 |
Correct |
40 ms |
2204 KB |
Output is correct |
29 |
Correct |
40 ms |
2188 KB |
Output is correct |
30 |
Correct |
40 ms |
2188 KB |
Output is correct |
31 |
Correct |
1 ms |
208 KB |
Output is correct |
32 |
Correct |
1 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 |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
1 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 |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
13 ms |
536 KB |
Output is correct |
17 |
Correct |
11 ms |
464 KB |
Output is correct |
18 |
Correct |
13 ms |
556 KB |
Output is correct |
19 |
Correct |
12 ms |
512 KB |
Output is correct |
20 |
Correct |
7 ms |
464 KB |
Output is correct |
21 |
Correct |
54 ms |
1048 KB |
Output is correct |
22 |
Correct |
54 ms |
1016 KB |
Output is correct |
23 |
Correct |
49 ms |
1084 KB |
Output is correct |
24 |
Correct |
56 ms |
1056 KB |
Output is correct |
25 |
Correct |
48 ms |
1104 KB |
Output is correct |
26 |
Correct |
51 ms |
1036 KB |
Output is correct |
27 |
Correct |
47 ms |
1084 KB |
Output is correct |
28 |
Correct |
56 ms |
1084 KB |
Output is correct |
29 |
Correct |
48 ms |
1060 KB |
Output is correct |
30 |
Correct |
26 ms |
1032 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |