# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
51047 |
2018-06-15T17:03:47 Z |
Abelyan |
Gap (APIO16_gap) |
C++17 |
|
84 ms |
3592 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MX=(ll)1000000000000000000;
const int MAXN=100006;
ll a[MAXN];
vector<ll> v;
long long findGap(int T, int n)
{
if (T==1){
ll mx,mn;
MinMax(0,MX,&mn,&mx);
int j=n-1;
int i=0;
while (mn!=-1){
a[i]=mn;
a[j]=mx;
//cout<<i<<" "<<" "<<j<<endl;
//cout<<mn<< " "<<mx<<endl;
i++;
j--;
if (i>j || mn+1>mx-1) break;
MinMax(mn+1,mx-1,&mn,&mx);
if (mn==mx && mn!=-1){
a[i]=mn;
break;
}
}
ll maxim=0;
for (int i=0;i<n-1;i++){
//cout<<a[i]<<endl;
maxim=max(maxim,a[i+1]-a[i]);
}
return maxim;
}
else{
ll mx,mn;
MinMax(0,MX,&mn,&mx);
v.push_back(mn);
ll del=(mx-mn-1)/(n-1);
ll qan=mx-mn-1-(n-1)*del;
//cout<<del<<" "<<qan<<endl;
ll nax=mn;
for (int i=0;i<n-1;i++){
if (i<qan){
ll l,r;
MinMax(nax+1,nax+del+1,&l,&r);
nax=nax+del+1;
//cout<<l<<" "<<r<<endl;
if (l!=-1){
v.push_back(l);
v.push_back(r);
}
}
else{
ll l,r;
MinMax(nax+1,nax+del,&l,&r);
nax=nax+del;
if (l!=-1){
v.push_back(l);
v.push_back(r);
}
}
}
v.push_back(mx);
ll maxim=0;
for (int i=0;i<v.size()-1;i++){
maxim=max(maxim,v[i+1]-v[i]);
}
return maxim;
}
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:70:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0;i<v.size()-1;i++){
~^~~~~~~~~~~
# |
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 |
416 KB |
Output is correct |
4 |
Correct |
3 ms |
416 KB |
Output is correct |
5 |
Correct |
2 ms |
620 KB |
Output is correct |
6 |
Correct |
3 ms |
620 KB |
Output is correct |
7 |
Correct |
2 ms |
620 KB |
Output is correct |
8 |
Correct |
3 ms |
620 KB |
Output is correct |
9 |
Correct |
2 ms |
620 KB |
Output is correct |
10 |
Correct |
2 ms |
620 KB |
Output is correct |
11 |
Correct |
2 ms |
684 KB |
Output is correct |
12 |
Correct |
4 ms |
684 KB |
Output is correct |
13 |
Correct |
3 ms |
684 KB |
Output is correct |
14 |
Correct |
3 ms |
704 KB |
Output is correct |
15 |
Correct |
3 ms |
704 KB |
Output is correct |
16 |
Correct |
17 ms |
1020 KB |
Output is correct |
17 |
Correct |
15 ms |
1020 KB |
Output is correct |
18 |
Correct |
16 ms |
1020 KB |
Output is correct |
19 |
Correct |
15 ms |
1020 KB |
Output is correct |
20 |
Correct |
12 ms |
1020 KB |
Output is correct |
21 |
Correct |
60 ms |
2152 KB |
Output is correct |
22 |
Correct |
60 ms |
2172 KB |
Output is correct |
23 |
Correct |
77 ms |
2172 KB |
Output is correct |
24 |
Correct |
58 ms |
2172 KB |
Output is correct |
25 |
Correct |
49 ms |
2172 KB |
Output is correct |
26 |
Correct |
57 ms |
2172 KB |
Output is correct |
27 |
Correct |
57 ms |
2172 KB |
Output is correct |
28 |
Correct |
74 ms |
2172 KB |
Output is correct |
29 |
Correct |
60 ms |
2172 KB |
Output is correct |
30 |
Correct |
42 ms |
2172 KB |
Output is correct |
31 |
Correct |
2 ms |
2172 KB |
Output is correct |
32 |
Correct |
2 ms |
2172 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2172 KB |
Output is correct |
2 |
Correct |
2 ms |
2172 KB |
Output is correct |
3 |
Correct |
2 ms |
2172 KB |
Output is correct |
4 |
Correct |
2 ms |
2172 KB |
Output is correct |
5 |
Correct |
3 ms |
2172 KB |
Output is correct |
6 |
Correct |
3 ms |
2172 KB |
Output is correct |
7 |
Correct |
2 ms |
2172 KB |
Output is correct |
8 |
Correct |
3 ms |
2172 KB |
Output is correct |
9 |
Correct |
2 ms |
2172 KB |
Output is correct |
10 |
Correct |
2 ms |
2172 KB |
Output is correct |
11 |
Correct |
3 ms |
2172 KB |
Output is correct |
12 |
Correct |
3 ms |
2172 KB |
Output is correct |
13 |
Correct |
4 ms |
2172 KB |
Output is correct |
14 |
Correct |
3 ms |
2172 KB |
Output is correct |
15 |
Correct |
3 ms |
2172 KB |
Output is correct |
16 |
Correct |
21 ms |
2172 KB |
Output is correct |
17 |
Correct |
21 ms |
2172 KB |
Output is correct |
18 |
Correct |
24 ms |
2172 KB |
Output is correct |
19 |
Correct |
22 ms |
2172 KB |
Output is correct |
20 |
Correct |
12 ms |
2172 KB |
Output is correct |
21 |
Correct |
78 ms |
2544 KB |
Output is correct |
22 |
Correct |
83 ms |
2544 KB |
Output is correct |
23 |
Correct |
78 ms |
2548 KB |
Output is correct |
24 |
Correct |
84 ms |
2588 KB |
Output is correct |
25 |
Correct |
75 ms |
3592 KB |
Output is correct |
26 |
Correct |
80 ms |
3592 KB |
Output is correct |
27 |
Correct |
80 ms |
3592 KB |
Output is correct |
28 |
Correct |
79 ms |
3592 KB |
Output is correct |
29 |
Correct |
81 ms |
3592 KB |
Output is correct |
30 |
Correct |
40 ms |
3592 KB |
Output is correct |
31 |
Correct |
2 ms |
3592 KB |
Output is correct |
32 |
Correct |
2 ms |
3592 KB |
Output is correct |