# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
667335 |
2022-12-01T07:02:04 Z |
Mahdi |
Gap (APIO16_gap) |
C++17 |
|
72 ms |
3268 KB |
#include<bits/stdc++.h>
#include "gap.h"
using namespace std;
#define all(v) v.begin(), v.end()
typedef long long ll;
long long findGap(int T, int N){
if(T==1){
vector<ll>v;
ll a=-1, b=1e18+1, c, d;
for(int i=0;i<N;i+=2){
if(a+1>b-1){
return 1/0;
}
MinMax(a+1, b-1, &c, &d);
v.push_back(c);
v.push_back(d);
a=c;
b=d;
}
sort(all(v));
ll ans=0;
for(int i=1;i<v.size();++i)
ans=max(ans, v[i]-v[i-1]);
return ans;
}
ll a, b;
MinMax(0, 1e18, &a, &b);
ll c=(b-a+N-2)/(N-1);
ll ans=c;
vector<ll>v;
ll d, e;
for(int i=1;i<N;++i){
MinMax(a+(i-1)*c+1, a+i*c, &d, &e);
if(d!=-1){
v.push_back(d);
v.push_back(e);
}
}
v.push_back(a);
sort(all(v));
for(int i=1;i<v.size();++i)
ans=max(ans, v[i]-v[i-1]);
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:13:13: warning: division by zero [-Wdiv-by-zero]
13 | return 1/0;
| ~^~
gap.cpp:23:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for(int i=1;i<v.size();++i)
| ~^~~~~~~~~
gap.cpp:42:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 | for(int i=1;i<v.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 |
1 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 |
1 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 |
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 |
12 ms |
820 KB |
Output is correct |
17 |
Correct |
10 ms |
848 KB |
Output is correct |
18 |
Correct |
10 ms |
848 KB |
Output is correct |
19 |
Correct |
11 ms |
924 KB |
Output is correct |
20 |
Correct |
8 ms |
848 KB |
Output is correct |
21 |
Correct |
41 ms |
2140 KB |
Output is correct |
22 |
Correct |
39 ms |
2204 KB |
Output is correct |
23 |
Correct |
39 ms |
2192 KB |
Output is correct |
24 |
Correct |
39 ms |
2192 KB |
Output is correct |
25 |
Correct |
35 ms |
2200 KB |
Output is correct |
26 |
Correct |
39 ms |
2248 KB |
Output is correct |
27 |
Correct |
39 ms |
2188 KB |
Output is correct |
28 |
Correct |
40 ms |
2228 KB |
Output is correct |
29 |
Correct |
40 ms |
2200 KB |
Output is correct |
30 |
Correct |
33 ms |
2248 KB |
Output is correct |
31 |
Incorrect |
0 ms |
208 KB |
Output isn't 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 |
1 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 |
1 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 |
336 KB |
Output is correct |
12 |
Correct |
2 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 |
2 ms |
336 KB |
Output is correct |
16 |
Correct |
20 ms |
848 KB |
Output is correct |
17 |
Correct |
15 ms |
812 KB |
Output is correct |
18 |
Correct |
18 ms |
864 KB |
Output is correct |
19 |
Correct |
14 ms |
848 KB |
Output is correct |
20 |
Correct |
6 ms |
464 KB |
Output is correct |
21 |
Correct |
58 ms |
2192 KB |
Output is correct |
22 |
Correct |
63 ms |
2204 KB |
Output is correct |
23 |
Correct |
72 ms |
2200 KB |
Output is correct |
24 |
Correct |
62 ms |
2276 KB |
Output is correct |
25 |
Correct |
70 ms |
3268 KB |
Output is correct |
26 |
Correct |
67 ms |
2216 KB |
Output is correct |
27 |
Correct |
60 ms |
2216 KB |
Output is correct |
28 |
Correct |
60 ms |
2244 KB |
Output is correct |
29 |
Correct |
61 ms |
2236 KB |
Output is correct |
30 |
Correct |
34 ms |
1440 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
1 ms |
208 KB |
Output is correct |