# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
122805 |
2019-06-29T09:57:13 Z |
tselmegkh |
Gap (APIO16_gap) |
C++14 |
|
70 ms |
1912 KB |
#include<bits/stdc++.h>
#include "gap.h"
using namespace std;
#define INF 1e9
#define MAX 200005
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define ull long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define nl '\n'
#define zai <<' '<<
#define all(a) a.begin(),a.end()
#define pc __builtin_popcount
#define debug(args...) cerr << #args << " = "; Dbg,args; cerr << nl;
struct Dbg { template<typename T> Dbg& operator,(const T& v) { cerr << v << ", "; return *this; } } Dbg;
template <typename T> ostream& operator<<(ostream& _o_, const vector<T>& _v_){
if(!_v_.empty()){_o_<<'[';copy(_v_.begin(),_v_.end(),ostream_iterator<T>(_o_,", "));_o_<<"\b\b]";}return _o_;}
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
template<class C> void mini(C &_a, C _b) { _a = min(_a, _b); }
template<class C> void maxi(C &_a, C _b) { _a = max(_a, _b); }
ull a[MAX];
ull findGap(int T,int n){
ull mn = 0, mx = 1e18;
int l = 0, r = n - 1;
if(T == 1){
ull f,s;
while(l <= r){
MinMax(mn, mx, &f, &s);
a[l] = f;
a[r] = s;
mn = f + 1;
mx = s - 1;
l++;
r--;
}
ull ans = 0;
for(int i = 1; i < n; i++){
maxi(ans, a[i] - a[i - 1]);
}
return ans;
}
else{
ull f, s;
MinMax(mn, mx, &f, &s);
a[0] = f;
a[n - 1] = s;
ull bef = a[0];
ull avdiff = (a[n - 1] - a[0]) / (n - 1);
ull ans = 0;
mn = a[0] + 1;
while(true){
if(mn > a[n - 1]){
return ans;
}
ull f, s;
MinMax(mn, mn + avdiff - 1, &f, &s);
if(f == -1 || s == -1){
mn += avdiff;
continue;
}
maxi(ans, f - bef);
mn += avdiff;
bef = s;
maxi(avdiff, ans);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
380 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
380 KB |
Output is correct |
11 |
Correct |
3 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
15 ms |
808 KB |
Output is correct |
17 |
Correct |
15 ms |
764 KB |
Output is correct |
18 |
Correct |
17 ms |
760 KB |
Output is correct |
19 |
Correct |
15 ms |
760 KB |
Output is correct |
20 |
Correct |
11 ms |
760 KB |
Output is correct |
21 |
Correct |
57 ms |
1912 KB |
Output is correct |
22 |
Correct |
57 ms |
1912 KB |
Output is correct |
23 |
Correct |
57 ms |
1912 KB |
Output is correct |
24 |
Correct |
59 ms |
1912 KB |
Output is correct |
25 |
Correct |
48 ms |
1912 KB |
Output is correct |
26 |
Correct |
57 ms |
1912 KB |
Output is correct |
27 |
Correct |
56 ms |
1912 KB |
Output is correct |
28 |
Correct |
56 ms |
1912 KB |
Output is correct |
29 |
Correct |
56 ms |
1912 KB |
Output is correct |
30 |
Correct |
44 ms |
1912 KB |
Output is correct |
31 |
Correct |
2 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
10 ms |
508 KB |
Output is correct |
17 |
Correct |
10 ms |
504 KB |
Output is correct |
18 |
Correct |
10 ms |
504 KB |
Output is correct |
19 |
Correct |
10 ms |
632 KB |
Output is correct |
20 |
Correct |
7 ms |
504 KB |
Output is correct |
21 |
Correct |
36 ms |
1140 KB |
Output is correct |
22 |
Correct |
36 ms |
1244 KB |
Output is correct |
23 |
Correct |
35 ms |
1144 KB |
Output is correct |
24 |
Correct |
35 ms |
1144 KB |
Output is correct |
25 |
Correct |
70 ms |
1144 KB |
Output is correct |
26 |
Correct |
36 ms |
1056 KB |
Output is correct |
27 |
Correct |
36 ms |
1148 KB |
Output is correct |
28 |
Correct |
36 ms |
1144 KB |
Output is correct |
29 |
Correct |
35 ms |
1144 KB |
Output is correct |
30 |
Correct |
27 ms |
1144 KB |
Output is correct |
31 |
Correct |
2 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
376 KB |
Output is correct |