# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
518271 |
2022-01-23T09:40:33 Z |
Evirir |
Gap (APIO16_gap) |
C++17 |
|
60 ms |
3340 KB |
#include <bits/stdc++.h>
#include "gap.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define cbug if(DEBUG) cout
#define setp(x) cout<<fixed<<setprecision(x)
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
//template<typename T>
//using pbds = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
ostream& operator<<(ostream &out, ii x){ out<<"("<<x.F<<","<<x.S<<")"; return out; }
template<typename T> void amax(T &a, T b){ a=max(a,b); }
template<typename T> void amin(T &a, T b){ a=min(a,b); }
const ll INF = ll(1e18);
const int MOD = 998244353;
const bool DEBUG = 0;
const int MAXN = 100005;
const int LG = 21;
ll mn, mx;
void query(ll L, ll R)
{
MinMax(L, R, &mn, &mx);
}
ll solve1(int n)
{
ll a[n];
mn=-1, mx=(ll)(1e18)+1;
for(int l=0, r=n-1; l<=r; l++, r--)
{
query(mn + 1, mx - 1);
a[l]=mn, a[r]=mx;
}
ll ans=0;
forn(i,1,n) ans=max(ans, a[i]-a[i-1]);
return ans;
}
ll solve2(int n)
{
query(0, (ll)1e18);
ll L=mn, R=mx;
ll len=(R-L+n-2) / (n-1);
vector<ll> v={mn};
forn(i,0,n-1)
{
query(L+i*len+1, L+(i+1)*len);
if(mn!=-1)
{
v.pb(mn); v.pb(mx);
}
}
ll ans=0;
forn(i,1,sz(v)) ans=max(ans, v[i]-v[i-1]);
return ans;
}
long long findGap(int T, int N)
{
return (T == 1 ? solve1(N) : solve2(N));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
284 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
292 KB |
Output is correct |
5 |
Correct |
0 ms |
200 KB |
Output is correct |
6 |
Correct |
0 ms |
200 KB |
Output is correct |
7 |
Correct |
1 ms |
316 KB |
Output is correct |
8 |
Correct |
1 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 |
10 ms |
676 KB |
Output is correct |
17 |
Correct |
10 ms |
664 KB |
Output is correct |
18 |
Correct |
9 ms |
672 KB |
Output is correct |
19 |
Correct |
9 ms |
584 KB |
Output is correct |
20 |
Correct |
7 ms |
680 KB |
Output is correct |
21 |
Correct |
33 ms |
1728 KB |
Output is correct |
22 |
Correct |
34 ms |
1808 KB |
Output is correct |
23 |
Correct |
39 ms |
1780 KB |
Output is correct |
24 |
Correct |
40 ms |
1816 KB |
Output is correct |
25 |
Correct |
34 ms |
1828 KB |
Output is correct |
26 |
Correct |
34 ms |
1804 KB |
Output is correct |
27 |
Correct |
41 ms |
1808 KB |
Output is correct |
28 |
Correct |
36 ms |
1860 KB |
Output is correct |
29 |
Correct |
34 ms |
1812 KB |
Output is correct |
30 |
Correct |
31 ms |
1812 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 |
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 |
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 |
13 ms |
888 KB |
Output is correct |
17 |
Correct |
12 ms |
840 KB |
Output is correct |
18 |
Correct |
12 ms |
824 KB |
Output is correct |
19 |
Correct |
12 ms |
840 KB |
Output is correct |
20 |
Correct |
6 ms |
456 KB |
Output is correct |
21 |
Correct |
50 ms |
2324 KB |
Output is correct |
22 |
Correct |
48 ms |
2184 KB |
Output is correct |
23 |
Correct |
60 ms |
2192 KB |
Output is correct |
24 |
Correct |
50 ms |
2192 KB |
Output is correct |
25 |
Correct |
49 ms |
3340 KB |
Output is correct |
26 |
Correct |
49 ms |
2196 KB |
Output is correct |
27 |
Correct |
51 ms |
2228 KB |
Output is correct |
28 |
Correct |
50 ms |
2180 KB |
Output is correct |
29 |
Correct |
55 ms |
2200 KB |
Output is correct |
30 |
Correct |
33 ms |
1444 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
0 ms |
200 KB |
Output is correct |