# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
532797 |
2022-03-03T23:33:41 Z |
new_acc |
Gap (APIO16_gap) |
C++14 |
|
68 ms |
1084 KB |
#include "gap.h"
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=1e3+10;
ll solve1(int n){
ll mn,mx;
ll curr1=0,curr2=1e18,last1=-1,last2=-1;
ll res=0;
for(int i=1;i<=(n+1)/2;i++){
MinMax(curr1,curr2,&mn,&mx);
if(last1!=-1) res=max({res,mn-last1,last2-mx});
last1=mn,last2=mx;
curr1=mn+1,curr2=mx-1;
}
return (n%2==0?max(res,last2-last1):res);
}
ll solve2(int n){
if(n<=6) return solve1(n);
ll mn,mx;
MinMax(0,1e18,&mn,&mx);
ll last=mx;
ll minim=(mx-mn)/(n-1LL);
ll curr=mn,res=minim;
for(ll i=curr+1;i<=last;i+=minim+1){
MinMax(i,i+minim,&mn,&mx);
if(mx==-1) continue;
res=max(res,mn-curr);
curr=mx;
}
return res;
}
ll findGap(int xd,int n){
if(xd==1) return solve1(n);
else return solve2(n);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
0 ms |
200 KB |
Output is correct |
7 |
Correct |
0 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
272 KB |
Output is correct |
9 |
Correct |
0 ms |
200 KB |
Output is correct |
10 |
Correct |
0 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
200 KB |
Output is correct |
12 |
Correct |
1 ms |
200 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
200 KB |
Output is correct |
16 |
Correct |
9 ms |
456 KB |
Output is correct |
17 |
Correct |
9 ms |
424 KB |
Output is correct |
18 |
Correct |
9 ms |
420 KB |
Output is correct |
19 |
Correct |
10 ms |
504 KB |
Output is correct |
20 |
Correct |
8 ms |
456 KB |
Output is correct |
21 |
Correct |
46 ms |
1076 KB |
Output is correct |
22 |
Correct |
35 ms |
1052 KB |
Output is correct |
23 |
Correct |
42 ms |
1012 KB |
Output is correct |
24 |
Correct |
37 ms |
1052 KB |
Output is correct |
25 |
Correct |
47 ms |
1056 KB |
Output is correct |
26 |
Correct |
38 ms |
1048 KB |
Output is correct |
27 |
Correct |
49 ms |
1084 KB |
Output is correct |
28 |
Correct |
44 ms |
992 KB |
Output is correct |
29 |
Correct |
39 ms |
968 KB |
Output is correct |
30 |
Correct |
30 ms |
968 KB |
Output is correct |
31 |
Correct |
0 ms |
200 KB |
Output is correct |
32 |
Correct |
0 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
0 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
0 ms |
200 KB |
Output is correct |
8 |
Correct |
0 ms |
200 KB |
Output is correct |
9 |
Correct |
0 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
200 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
17 ms |
456 KB |
Output is correct |
17 |
Correct |
12 ms |
456 KB |
Output is correct |
18 |
Correct |
12 ms |
420 KB |
Output is correct |
19 |
Correct |
13 ms |
508 KB |
Output is correct |
20 |
Correct |
6 ms |
456 KB |
Output is correct |
21 |
Correct |
56 ms |
1052 KB |
Output is correct |
22 |
Correct |
64 ms |
1076 KB |
Output is correct |
23 |
Correct |
55 ms |
960 KB |
Output is correct |
24 |
Correct |
51 ms |
1048 KB |
Output is correct |
25 |
Correct |
61 ms |
960 KB |
Output is correct |
26 |
Correct |
52 ms |
1036 KB |
Output is correct |
27 |
Correct |
52 ms |
1056 KB |
Output is correct |
28 |
Correct |
60 ms |
1052 KB |
Output is correct |
29 |
Correct |
68 ms |
1072 KB |
Output is correct |
30 |
Correct |
29 ms |
1020 KB |
Output is correct |
31 |
Correct |
0 ms |
200 KB |
Output is correct |
32 |
Correct |
1 ms |
200 KB |
Output is correct |