# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
739694 |
2023-05-11T04:12:33 Z |
ReLice |
Gap (APIO16_gap) |
C++14 |
|
60 ms |
2252 KB |
#include "gap.h"
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size()
using namespace std;
const ll inf=1e18+7;
long long findGap(int t, int n){
ll ans=0,a,b,c,d,i,j,l,r;
if(t==1){
a=1,b=inf;
MinMax(a,b,&c,&d);
vector <ll> v;
v.pb(c);
v.pb(d);
for(i=1;i<(n+1)/2;i++){
a=c+1;
b=d-1;
MinMax(a,b,&c,&d);
v.pb(c);
v.pb(d);
}
sort(v.begin(),v.end());
for(i=1;i<v.sz;i++){
ans=max(ans,v[i]-v[i-1]);
}
}
else{
a=1,b=inf;
MinMax(a,b,&c,&d);
vector <ll> v;
v.pb(c),v.pb(d);
l=d,r=c;
j=(d-c-1)%(n-1);
for(i=r+1;i<l;i+=(l-r-1)/(n-1)){
a=i;
if(j>0){
i++;
j--;
}
b=i+(l-r-1)/(n-1)-1;
MinMax(a,b,&c,&d);
if(c==-1) continue;
v.pb(c);
if(c!=d)v.pb(d);
}
sort(v.begin(),v.end());
for(i=1;i<v.sz;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:24:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | for(i=1;i<v.sz;i++){
| ^
gap.cpp:48:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
48 | for(i=1;i<v.sz;i++){
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 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 |
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 |
848 KB |
Output is correct |
17 |
Correct |
10 ms |
848 KB |
Output is correct |
18 |
Correct |
12 ms |
848 KB |
Output is correct |
19 |
Correct |
12 ms |
848 KB |
Output is correct |
20 |
Correct |
13 ms |
848 KB |
Output is correct |
21 |
Correct |
41 ms |
2200 KB |
Output is correct |
22 |
Correct |
39 ms |
2200 KB |
Output is correct |
23 |
Correct |
40 ms |
2220 KB |
Output is correct |
24 |
Correct |
48 ms |
2204 KB |
Output is correct |
25 |
Correct |
39 ms |
2236 KB |
Output is correct |
26 |
Correct |
43 ms |
2204 KB |
Output is correct |
27 |
Correct |
41 ms |
2248 KB |
Output is correct |
28 |
Correct |
42 ms |
2240 KB |
Output is correct |
29 |
Correct |
41 ms |
2204 KB |
Output is correct |
30 |
Correct |
34 ms |
2164 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 |
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 |
2 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
2 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 |
896 KB |
Output is correct |
17 |
Correct |
13 ms |
848 KB |
Output is correct |
18 |
Correct |
12 ms |
864 KB |
Output is correct |
19 |
Correct |
14 ms |
848 KB |
Output is correct |
20 |
Correct |
7 ms |
464 KB |
Output is correct |
21 |
Correct |
60 ms |
2204 KB |
Output is correct |
22 |
Correct |
60 ms |
2248 KB |
Output is correct |
23 |
Correct |
56 ms |
2208 KB |
Output is correct |
24 |
Correct |
54 ms |
2196 KB |
Output is correct |
25 |
Correct |
52 ms |
2200 KB |
Output is correct |
26 |
Correct |
56 ms |
2192 KB |
Output is correct |
27 |
Correct |
53 ms |
2192 KB |
Output is correct |
28 |
Correct |
57 ms |
2252 KB |
Output is correct |
29 |
Correct |
60 ms |
2196 KB |
Output is correct |
30 |
Correct |
32 ms |
1484 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
1 ms |
208 KB |
Output is correct |