# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
499598 |
2021-12-28T23:46:06 Z |
iliccmarko |
Gap (APIO16_gap) |
C++14 |
|
62 ms |
3220 KB |
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
#define ll long long
#define endl "\n"
#define INF 1000000000
#define LINF 10000000000000000LL
#define pb push_back
#define all(x) x.begin(), x.end()
#define len(s) (int)s.size()
#define test_case { int t; cin>>t; while(t--)solve(); }
#define single_case solve();
#define line cerr<<"----------"<<endl;
#define ios { /*ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);*/ }
#define mod 1000000007LL
/*
void MinMax(ll l, ll r, ll *mini, ll *maks)
{
cout<<l<<' '<<r<<endl;
ll x;
cin>>x;
*mini = x;
cin>>x;
*maks = x;
}
*/
ll findGap(int t, int n)
{
if(t==1LL)
{
deque<ll> dq;
vector<pair<ll, ll> > v;
ll l = 1LL;
ll r = (ll)1e18;
for(int i = 1;i<=(n+1)/2;i++)
{
ll mini, maks;
MinMax(l, r, &mini, &maks);
v.pb(make_pair(mini, maks));
l = mini + 1;
r = maks - 1;
}
for(int i = (n+1)/2-1;i>=0;i--)
{
if(v[i].first!=v[i].second)
{
dq.pb(v[i].second);
dq.push_front(v[i].first);
}
else
{
dq.pb(v[i].first);
}
}
ll maks = 1;
for(int i = 1;i<len(dq);i++)
{
maks = max(maks, dq[i] - dq[i-1]);
}
return maks;
}
else
{
ll l, r, ans, mini, maks;
l = 1LL;
r = 1e18;
MinMax(l, r, &mini, &maks);
if(n==2)
{
return maks - mini;
}
vector<pair<ll, ll> > v;
v.pb(make_pair(mini, mini));
l = mini + 1;
r = maks - 1;
ll o = maks;
ll d = (r-l+1)/((ll)n-2LL);
ll rem = (r-l+1)%((ll)n-2LL);
for(int i = 0;i<n-2;i++)
{
ll w = d;
if(i<rem) w++;
MinMax(l, l + w - 1LL, &mini, &maks);
if(mini!=-1) v.pb(make_pair(mini, maks));
l += w;
}
v.pb(make_pair(o, o));
ans = 1;
for(int i = 1;i<len(v);i++)
{
ans = max(ans, v[i].first - v[i-1].second);
}
//cout<<ans<<endl;
return ans;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 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 |
0 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 |
0 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 |
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 |
9 ms |
856 KB |
Output is correct |
17 |
Correct |
9 ms |
884 KB |
Output is correct |
18 |
Correct |
11 ms |
840 KB |
Output is correct |
19 |
Correct |
9 ms |
840 KB |
Output is correct |
20 |
Correct |
7 ms |
840 KB |
Output is correct |
21 |
Correct |
37 ms |
2700 KB |
Output is correct |
22 |
Correct |
38 ms |
2640 KB |
Output is correct |
23 |
Correct |
35 ms |
2700 KB |
Output is correct |
24 |
Correct |
39 ms |
2692 KB |
Output is correct |
25 |
Correct |
32 ms |
2656 KB |
Output is correct |
26 |
Correct |
38 ms |
2640 KB |
Output is correct |
27 |
Correct |
39 ms |
2712 KB |
Output is correct |
28 |
Correct |
35 ms |
2712 KB |
Output is correct |
29 |
Correct |
47 ms |
2700 KB |
Output is correct |
30 |
Correct |
28 ms |
2664 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 |
200 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 |
0 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 |
0 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 |
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 |
15 ms |
952 KB |
Output is correct |
17 |
Correct |
13 ms |
884 KB |
Output is correct |
18 |
Correct |
14 ms |
840 KB |
Output is correct |
19 |
Correct |
12 ms |
912 KB |
Output is correct |
20 |
Correct |
7 ms |
456 KB |
Output is correct |
21 |
Correct |
50 ms |
2232 KB |
Output is correct |
22 |
Correct |
51 ms |
2252 KB |
Output is correct |
23 |
Correct |
51 ms |
2224 KB |
Output is correct |
24 |
Correct |
62 ms |
2232 KB |
Output is correct |
25 |
Correct |
46 ms |
3220 KB |
Output is correct |
26 |
Correct |
49 ms |
2192 KB |
Output is correct |
27 |
Correct |
53 ms |
2200 KB |
Output is correct |
28 |
Correct |
52 ms |
2200 KB |
Output is correct |
29 |
Correct |
57 ms |
2200 KB |
Output is correct |
30 |
Correct |
30 ms |
1472 KB |
Output is correct |
31 |
Correct |
0 ms |
200 KB |
Output is correct |
32 |
Correct |
0 ms |
200 KB |
Output is correct |