# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
404617 |
2021-05-14T18:15:55 Z |
ritul_kr_singh |
Gap (APIO16_gap) |
C++17 |
|
66 ms |
3160 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sp << ' ' <<
#define nl << '\n'
#include "gap.h"
const ll INF = 1e18;
ll x, y;
ll findGap(int T, int n){
ll ans = 0;
if(T == 1){
vector<ll> a, b;
ll low = 0, high = INF;
int done = 0;
while(done < n){
MinMax(low, high, &x, &y);
a.push_back(x);
++done;
if(x < y) b.push_back(y), ++done;
low = x + 1LL;
high = y - 1LL;
}
while(!b.empty()) a.push_back(b.back()), b.pop_back();
for(int i=1; i<n; ++i) ans = max(ans, a[i]-a[i-1]);
}else{
vector<pair<ll, ll>> a;
ll low, high;
MinMax(0, INF, &low, &high);
a.emplace_back(-1, low);
ll w = (high - low - 2LL) / ((ll)n - 1LL);
for(ll s=low+1; s<high; s+=w+1){
MinMax(s, s+w, &x, &y);
if(x >= 0) a.emplace_back(x, y);
}
a.emplace_back(high, -1);
for(int i=1; i<(int)a.size(); ++i) ans = max(ans, a[i].first - a[i-1].second);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
1 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
200 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
2 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 |
11 ms |
968 KB |
Output is correct |
17 |
Correct |
11 ms |
968 KB |
Output is correct |
18 |
Correct |
11 ms |
1008 KB |
Output is correct |
19 |
Correct |
12 ms |
948 KB |
Output is correct |
20 |
Correct |
9 ms |
968 KB |
Output is correct |
21 |
Correct |
45 ms |
2608 KB |
Output is correct |
22 |
Correct |
49 ms |
2620 KB |
Output is correct |
23 |
Correct |
44 ms |
2620 KB |
Output is correct |
24 |
Correct |
45 ms |
2584 KB |
Output is correct |
25 |
Correct |
40 ms |
2636 KB |
Output is correct |
26 |
Correct |
43 ms |
2612 KB |
Output is correct |
27 |
Correct |
45 ms |
2620 KB |
Output is correct |
28 |
Correct |
55 ms |
2620 KB |
Output is correct |
29 |
Correct |
61 ms |
2532 KB |
Output is correct |
30 |
Correct |
36 ms |
2612 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
1 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
200 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
11 |
Correct |
2 ms |
328 KB |
Output is correct |
12 |
Correct |
2 ms |
328 KB |
Output is correct |
13 |
Correct |
2 ms |
328 KB |
Output is correct |
14 |
Correct |
2 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
15 ms |
852 KB |
Output is correct |
17 |
Correct |
16 ms |
868 KB |
Output is correct |
18 |
Correct |
15 ms |
840 KB |
Output is correct |
19 |
Correct |
15 ms |
840 KB |
Output is correct |
20 |
Correct |
8 ms |
508 KB |
Output is correct |
21 |
Correct |
63 ms |
2196 KB |
Output is correct |
22 |
Correct |
65 ms |
2200 KB |
Output is correct |
23 |
Correct |
63 ms |
2200 KB |
Output is correct |
24 |
Correct |
62 ms |
2236 KB |
Output is correct |
25 |
Correct |
57 ms |
3160 KB |
Output is correct |
26 |
Correct |
65 ms |
2232 KB |
Output is correct |
27 |
Correct |
65 ms |
2232 KB |
Output is correct |
28 |
Correct |
66 ms |
2232 KB |
Output is correct |
29 |
Correct |
61 ms |
2196 KB |
Output is correct |
30 |
Correct |
43 ms |
1472 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
1 ms |
200 KB |
Output is correct |