# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
61136 |
2018-07-25T08:38:04 Z |
istlemin |
Gap (APIO16_gap) |
C++14 |
|
118 ms |
4484 KB |
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
void ask(ll l,ll r, ll *mn,ll *mx){
ll ansMn,ansMx;
MinMax(l,r-1,&ansMn,&ansMx);
(*mn) = ansMn;
(*mx) = ansMx;
}
long long findGap(int T, int N) {
ll t = T;
ll n = N;
if(t==1){
vi a;
ll l = -1;
ll r = 2e18;
while(true){
ll mn,mx;
if(a.size()==n) break;
ask(l,r,&mn,&mx);
l = mn+1;
r = mx;
a.push_back(mn);
if(mn==mx) break;
a.push_back(mx);
}
sort(all(a));
ll mxGap = 0;
rep(i,0,n-1) mxGap = max(mxGap,a[i+1]-a[i]);
return mxGap;
} else {
ll dn,up;
ask(-1,2e18,&dn,&up);
up++;
vi a;
vi endPoints;
endPoints.push_back(dn);
rep(i,0,n){
if(i<(up-dn)%n)
endPoints.push_back(endPoints[endPoints.size()-1]+(up-dn)/n+1);
else
endPoints.push_back(endPoints[endPoints.size()-1]+(up-dn)/n);
}
rep(i,0,n){
ll l = endPoints[i];
ll r = endPoints[i+1];
ll mn,mx;
ask(l,r,&mn,&mx);
a.push_back(mn);
a.push_back(mx);
}
sort(all(a));
ll mxGap = 0;
rep(i,0,a.size()-1) mxGap = max(mxGap,a[i+1]-a[i]);
//cout<<"yes"<<endl;
return mxGap;
}
return 0;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:32:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(a.size()==n) break;
~~~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
492 KB |
Output is correct |
3 |
Correct |
2 ms |
572 KB |
Output is correct |
4 |
Correct |
3 ms |
572 KB |
Output is correct |
5 |
Correct |
2 ms |
572 KB |
Output is correct |
6 |
Correct |
0 ms |
596 KB |
Output is correct |
7 |
Correct |
4 ms |
596 KB |
Output is correct |
8 |
Correct |
2 ms |
596 KB |
Output is correct |
9 |
Correct |
3 ms |
600 KB |
Output is correct |
10 |
Correct |
4 ms |
600 KB |
Output is correct |
11 |
Correct |
3 ms |
600 KB |
Output is correct |
12 |
Correct |
4 ms |
600 KB |
Output is correct |
13 |
Correct |
4 ms |
600 KB |
Output is correct |
14 |
Correct |
4 ms |
620 KB |
Output is correct |
15 |
Correct |
3 ms |
620 KB |
Output is correct |
16 |
Correct |
20 ms |
1132 KB |
Output is correct |
17 |
Correct |
23 ms |
1132 KB |
Output is correct |
18 |
Correct |
21 ms |
1132 KB |
Output is correct |
19 |
Correct |
22 ms |
1132 KB |
Output is correct |
20 |
Correct |
14 ms |
1132 KB |
Output is correct |
21 |
Correct |
70 ms |
2532 KB |
Output is correct |
22 |
Correct |
71 ms |
2532 KB |
Output is correct |
23 |
Correct |
67 ms |
2532 KB |
Output is correct |
24 |
Correct |
73 ms |
2532 KB |
Output is correct |
25 |
Correct |
82 ms |
2532 KB |
Output is correct |
26 |
Correct |
79 ms |
2556 KB |
Output is correct |
27 |
Correct |
77 ms |
2556 KB |
Output is correct |
28 |
Correct |
99 ms |
2556 KB |
Output is correct |
29 |
Correct |
70 ms |
2556 KB |
Output is correct |
30 |
Correct |
49 ms |
2556 KB |
Output is correct |
31 |
Correct |
3 ms |
2556 KB |
Output is correct |
32 |
Correct |
3 ms |
2556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
2556 KB |
Partially correct |
2 |
Partially correct |
3 ms |
2556 KB |
Partially correct |
3 |
Partially correct |
4 ms |
2556 KB |
Partially correct |
4 |
Partially correct |
3 ms |
2556 KB |
Partially correct |
5 |
Partially correct |
3 ms |
2556 KB |
Partially correct |
6 |
Partially correct |
3 ms |
2556 KB |
Partially correct |
7 |
Partially correct |
2 ms |
2556 KB |
Partially correct |
8 |
Partially correct |
3 ms |
2556 KB |
Partially correct |
9 |
Partially correct |
3 ms |
2556 KB |
Partially correct |
10 |
Partially correct |
3 ms |
2556 KB |
Partially correct |
11 |
Partially correct |
4 ms |
2556 KB |
Partially correct |
12 |
Partially correct |
4 ms |
2556 KB |
Partially correct |
13 |
Partially correct |
4 ms |
2556 KB |
Partially correct |
14 |
Partially correct |
4 ms |
2556 KB |
Partially correct |
15 |
Partially correct |
5 ms |
2556 KB |
Partially correct |
16 |
Partially correct |
26 ms |
2556 KB |
Partially correct |
17 |
Partially correct |
29 ms |
2556 KB |
Partially correct |
18 |
Partially correct |
33 ms |
2556 KB |
Partially correct |
19 |
Partially correct |
30 ms |
2556 KB |
Partially correct |
20 |
Partially correct |
18 ms |
2556 KB |
Partially correct |
21 |
Partially correct |
97 ms |
4344 KB |
Partially correct |
22 |
Partially correct |
111 ms |
4344 KB |
Partially correct |
23 |
Partially correct |
99 ms |
4352 KB |
Partially correct |
24 |
Partially correct |
101 ms |
4352 KB |
Partially correct |
25 |
Partially correct |
96 ms |
4352 KB |
Partially correct |
26 |
Partially correct |
96 ms |
4352 KB |
Partially correct |
27 |
Partially correct |
92 ms |
4388 KB |
Partially correct |
28 |
Partially correct |
115 ms |
4388 KB |
Partially correct |
29 |
Partially correct |
118 ms |
4484 KB |
Partially correct |
30 |
Partially correct |
62 ms |
4484 KB |
Partially correct |
31 |
Partially correct |
3 ms |
4484 KB |
Partially correct |
32 |
Partially correct |
3 ms |
4484 KB |
Partially correct |