# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
43635 |
2018-03-18T21:34:51 Z |
spencercompton |
Gap (APIO16_gap) |
C++14 |
|
83 ms |
3556 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
// vector<long long> li;
// void MinMax(long long a, long long b, long long *c, long long *d){
// vector<long long> ar;
// for(int i = 0; i<li.size(); i++){
// if(li[i]>=a && li[i]<=b){
// ar.push_back(li[i]);
// }
// }
// if(ar.size()==0){
// *c = -1;
// *d = -1;
// }
// else{
// *c = ar[0];
// *d = ar[ar.size()-1];
// }
// }
long long findGap(int T, int N)
{
long long maxval = 1000000000000000000LL;
long long mn, mx;
MinMax(1,maxval,&mn,&mx);
cout << mn << " " << mx << endl;
long long s = mn;
long long e = mx;
if(N==1){
return e-s-1LL;
}
long long ans = (e-s)/((long long)N-1LL)-1LL;
if((e-s)%((long long)N-1LL)!=0){
ans++;
}
long long last = s;
long long check = ans+1LL;
vector<long long> all;
all.push_back(s);
for(long long i = s+1LL; i<e; i+=check){
long long r = min(e-1LL,i+check-1LL);
MinMax(i,r,&mn,&mx);
if(mn!=-1){
all.push_back(mn);
all.push_back(mx);
}
}
all.push_back(e);
for(int i = 1; i<all.size(); i++){
ans = max(ans,all[i]-all[i-1]);
}
return ans;
}
// int main(){
// li.push_back(2);
// li.push_back(3);
// li.push_back(6);
// li.push_back(8);
// cout << findGap(0,4) << endl;
// }
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:49:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 1; i<all.size(); i++){
^
gap.cpp:36:15: warning: unused variable 'last' [-Wunused-variable]
long long last = s;
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Expected EOLN |
2 |
Incorrect |
1 ms |
376 KB |
Expected EOLN |
3 |
Incorrect |
1 ms |
444 KB |
Expected EOLN |
4 |
Incorrect |
2 ms |
588 KB |
Expected EOLN |
5 |
Incorrect |
2 ms |
588 KB |
Expected EOLN |
6 |
Incorrect |
1 ms |
588 KB |
Expected EOLN |
7 |
Incorrect |
1 ms |
588 KB |
Expected EOLN |
8 |
Incorrect |
1 ms |
588 KB |
Expected EOLN |
9 |
Incorrect |
1 ms |
588 KB |
Expected EOLN |
10 |
Incorrect |
1 ms |
588 KB |
Expected EOLN |
11 |
Incorrect |
2 ms |
704 KB |
Expected EOLN |
12 |
Incorrect |
2 ms |
736 KB |
Expected EOLN |
13 |
Incorrect |
2 ms |
736 KB |
Expected EOLN |
14 |
Incorrect |
2 ms |
736 KB |
Expected EOLN |
15 |
Incorrect |
2 ms |
736 KB |
Expected EOLN |
16 |
Incorrect |
19 ms |
1176 KB |
Expected EOLN |
17 |
Incorrect |
19 ms |
1176 KB |
Expected EOLN |
18 |
Incorrect |
21 ms |
1176 KB |
Expected EOLN |
19 |
Incorrect |
19 ms |
1176 KB |
Expected EOLN |
20 |
Incorrect |
9 ms |
1176 KB |
Expected EOLN |
21 |
Incorrect |
75 ms |
2532 KB |
Expected EOLN |
22 |
Incorrect |
74 ms |
2532 KB |
Expected EOLN |
23 |
Incorrect |
76 ms |
2532 KB |
Expected EOLN |
24 |
Incorrect |
75 ms |
2532 KB |
Expected EOLN |
25 |
Incorrect |
70 ms |
3552 KB |
Expected EOLN |
26 |
Incorrect |
74 ms |
3552 KB |
Expected EOLN |
27 |
Incorrect |
83 ms |
3552 KB |
Expected EOLN |
28 |
Incorrect |
74 ms |
3552 KB |
Expected EOLN |
29 |
Incorrect |
76 ms |
3552 KB |
Expected EOLN |
30 |
Incorrect |
41 ms |
3552 KB |
Expected EOLN |
31 |
Incorrect |
2 ms |
3552 KB |
Expected EOLN |
32 |
Incorrect |
1 ms |
3552 KB |
Expected EOLN |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
3552 KB |
Expected EOLN |
2 |
Incorrect |
2 ms |
3552 KB |
Expected EOLN |
3 |
Incorrect |
1 ms |
3552 KB |
Expected EOLN |
4 |
Incorrect |
2 ms |
3552 KB |
Expected EOLN |
5 |
Incorrect |
2 ms |
3552 KB |
Expected EOLN |
6 |
Incorrect |
1 ms |
3552 KB |
Expected EOLN |
7 |
Incorrect |
2 ms |
3552 KB |
Expected EOLN |
8 |
Incorrect |
1 ms |
3552 KB |
Expected EOLN |
9 |
Incorrect |
1 ms |
3552 KB |
Expected EOLN |
10 |
Incorrect |
2 ms |
3552 KB |
Expected EOLN |
11 |
Incorrect |
2 ms |
3552 KB |
Expected EOLN |
12 |
Incorrect |
2 ms |
3552 KB |
Expected EOLN |
13 |
Incorrect |
2 ms |
3552 KB |
Expected EOLN |
14 |
Incorrect |
3 ms |
3552 KB |
Expected EOLN |
15 |
Incorrect |
3 ms |
3552 KB |
Expected EOLN |
16 |
Incorrect |
20 ms |
3552 KB |
Expected EOLN |
17 |
Incorrect |
19 ms |
3552 KB |
Expected EOLN |
18 |
Incorrect |
20 ms |
3552 KB |
Expected EOLN |
19 |
Incorrect |
19 ms |
3552 KB |
Expected EOLN |
20 |
Incorrect |
9 ms |
3552 KB |
Expected EOLN |
21 |
Incorrect |
75 ms |
3552 KB |
Expected EOLN |
22 |
Incorrect |
76 ms |
3552 KB |
Expected EOLN |
23 |
Incorrect |
75 ms |
3552 KB |
Expected EOLN |
24 |
Incorrect |
75 ms |
3552 KB |
Expected EOLN |
25 |
Incorrect |
78 ms |
3556 KB |
Expected EOLN |
26 |
Incorrect |
74 ms |
3556 KB |
Expected EOLN |
27 |
Incorrect |
73 ms |
3556 KB |
Expected EOLN |
28 |
Incorrect |
76 ms |
3556 KB |
Expected EOLN |
29 |
Incorrect |
76 ms |
3556 KB |
Expected EOLN |
30 |
Incorrect |
40 ms |
3556 KB |
Expected EOLN |
31 |
Incorrect |
1 ms |
3556 KB |
Expected EOLN |
32 |
Incorrect |
1 ms |
3556 KB |
Expected EOLN |