# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
667336 |
2022-12-01T07:04:17 Z |
Mahdi |
Gap (APIO16_gap) |
C++17 |
|
70 ms |
3288 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);
if(c==-1)
return 1/0;
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:17:13: warning: division by zero [-Wdiv-by-zero]
17 | return 1/0;
| ~^~
gap.cpp:25:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | for(int i=1;i<v.size();++i)
| ~^~~~~~~~~
gap.cpp:44:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | 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 |
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 |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 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 |
12 ms |
912 KB |
Output is correct |
18 |
Correct |
12 ms |
912 KB |
Output is correct |
19 |
Correct |
10 ms |
820 KB |
Output is correct |
20 |
Correct |
9 ms |
848 KB |
Output is correct |
21 |
Correct |
41 ms |
2224 KB |
Output is correct |
22 |
Correct |
43 ms |
2240 KB |
Output is correct |
23 |
Correct |
52 ms |
2208 KB |
Output is correct |
24 |
Correct |
41 ms |
2180 KB |
Output is correct |
25 |
Correct |
35 ms |
2208 KB |
Output is correct |
26 |
Correct |
43 ms |
2208 KB |
Output is correct |
27 |
Correct |
52 ms |
2208 KB |
Output is correct |
28 |
Correct |
41 ms |
2296 KB |
Output is correct |
29 |
Correct |
41 ms |
2208 KB |
Output is correct |
30 |
Correct |
34 ms |
2240 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 |
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 |
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 |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
19 ms |
860 KB |
Output is correct |
17 |
Correct |
14 ms |
808 KB |
Output is correct |
18 |
Correct |
15 ms |
848 KB |
Output is correct |
19 |
Correct |
17 ms |
860 KB |
Output is correct |
20 |
Correct |
7 ms |
464 KB |
Output is correct |
21 |
Correct |
70 ms |
2160 KB |
Output is correct |
22 |
Correct |
64 ms |
2204 KB |
Output is correct |
23 |
Correct |
61 ms |
2240 KB |
Output is correct |
24 |
Correct |
64 ms |
2204 KB |
Output is correct |
25 |
Correct |
62 ms |
3288 KB |
Output is correct |
26 |
Correct |
67 ms |
2204 KB |
Output is correct |
27 |
Correct |
64 ms |
2240 KB |
Output is correct |
28 |
Correct |
65 ms |
2240 KB |
Output is correct |
29 |
Correct |
65 ms |
2316 KB |
Output is correct |
30 |
Correct |
30 ms |
1480 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
1 ms |
208 KB |
Output is correct |