# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
68126 |
2018-08-16T04:10:49 Z |
shoemakerjo |
Gap (APIO16_gap) |
C++14 |
|
91 ms |
3568 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll findGap(int T, int N)
{
if (T == 1) {
vector<ll> nums;
ll lo = 1;
ll hi = 1000000000000000000LL;
int tseen = 0;
while (lo < hi) {
ll c1, c2;
MinMax(lo, hi, &c1, &c2);
nums.push_back(c1);
nums.push_back(c2);
tseen += 2;
if (tseen >= N) break;
lo = c1+1;
hi = c2-1;
}
ll ans = 0LL;
sort(nums.begin(), nums.end());
for (int i = 1; i < nums.size(); i++) {
ans = max(ans, nums[i]-nums[i-1]);
}
return ans;
}
//this is for T = 2
ll lo, hi;
MinMax(1, 1000000000000000000LL, &lo, &hi);
ll alph = (hi-lo)/N;
if ((hi-lo)%N != 0) alph+=1LL;
vector<ll> nums; //all the ones we care about
ll st = lo+1LL;
nums.push_back(lo);
while (st <= hi) {
ll c1, c2;
MinMax(st, st+alph, &c1, &c2);
if (c1 != -1) {
nums.push_back(c1);
nums.push_back(c2);
}
st += alph+1LL;
}
ll ans = alph;
for (int i = 1; i < nums.size(); i++) {
ans = max(ans, nums[i]-nums[i-1]);
}
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:26:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 1; i < nums.size(); i++) {
~~^~~~~~~~~~~~~
gap.cpp:51:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 1; i < nums.size(); i++) {
~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
488 KB |
Output is correct |
3 |
Correct |
4 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
488 KB |
Output is correct |
5 |
Correct |
3 ms |
516 KB |
Output is correct |
6 |
Correct |
2 ms |
644 KB |
Output is correct |
7 |
Correct |
3 ms |
644 KB |
Output is correct |
8 |
Correct |
2 ms |
644 KB |
Output is correct |
9 |
Correct |
3 ms |
644 KB |
Output is correct |
10 |
Correct |
2 ms |
644 KB |
Output is correct |
11 |
Correct |
3 ms |
692 KB |
Output is correct |
12 |
Correct |
4 ms |
692 KB |
Output is correct |
13 |
Correct |
3 ms |
708 KB |
Output is correct |
14 |
Correct |
3 ms |
708 KB |
Output is correct |
15 |
Correct |
4 ms |
708 KB |
Output is correct |
16 |
Correct |
17 ms |
1092 KB |
Output is correct |
17 |
Correct |
17 ms |
1092 KB |
Output is correct |
18 |
Correct |
22 ms |
1124 KB |
Output is correct |
19 |
Correct |
16 ms |
1124 KB |
Output is correct |
20 |
Correct |
13 ms |
1380 KB |
Output is correct |
21 |
Correct |
63 ms |
2532 KB |
Output is correct |
22 |
Correct |
61 ms |
2532 KB |
Output is correct |
23 |
Correct |
63 ms |
2532 KB |
Output is correct |
24 |
Correct |
62 ms |
2532 KB |
Output is correct |
25 |
Correct |
58 ms |
2664 KB |
Output is correct |
26 |
Correct |
66 ms |
2672 KB |
Output is correct |
27 |
Correct |
67 ms |
2672 KB |
Output is correct |
28 |
Correct |
62 ms |
2672 KB |
Output is correct |
29 |
Correct |
87 ms |
2672 KB |
Output is correct |
30 |
Correct |
48 ms |
2672 KB |
Output is correct |
31 |
Correct |
4 ms |
2672 KB |
Output is correct |
32 |
Correct |
3 ms |
2672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2672 KB |
Output is correct |
2 |
Correct |
2 ms |
2672 KB |
Output is correct |
3 |
Correct |
2 ms |
2672 KB |
Output is correct |
4 |
Correct |
2 ms |
2672 KB |
Output is correct |
5 |
Correct |
2 ms |
2672 KB |
Output is correct |
6 |
Correct |
2 ms |
2672 KB |
Output is correct |
7 |
Correct |
3 ms |
2672 KB |
Output is correct |
8 |
Correct |
2 ms |
2672 KB |
Output is correct |
9 |
Correct |
2 ms |
2672 KB |
Output is correct |
10 |
Correct |
3 ms |
2672 KB |
Output is correct |
11 |
Correct |
4 ms |
2672 KB |
Output is correct |
12 |
Correct |
4 ms |
2672 KB |
Output is correct |
13 |
Correct |
4 ms |
2672 KB |
Output is correct |
14 |
Correct |
4 ms |
2672 KB |
Output is correct |
15 |
Correct |
4 ms |
2672 KB |
Output is correct |
16 |
Correct |
24 ms |
2672 KB |
Output is correct |
17 |
Correct |
23 ms |
2672 KB |
Output is correct |
18 |
Correct |
24 ms |
2672 KB |
Output is correct |
19 |
Correct |
23 ms |
2672 KB |
Output is correct |
20 |
Correct |
11 ms |
2672 KB |
Output is correct |
21 |
Correct |
79 ms |
2672 KB |
Output is correct |
22 |
Correct |
80 ms |
2676 KB |
Output is correct |
23 |
Correct |
84 ms |
2676 KB |
Output is correct |
24 |
Correct |
81 ms |
2676 KB |
Output is correct |
25 |
Correct |
84 ms |
3568 KB |
Output is correct |
26 |
Correct |
79 ms |
3568 KB |
Output is correct |
27 |
Correct |
91 ms |
3568 KB |
Output is correct |
28 |
Correct |
77 ms |
3568 KB |
Output is correct |
29 |
Correct |
81 ms |
3568 KB |
Output is correct |
30 |
Correct |
66 ms |
3568 KB |
Output is correct |
31 |
Correct |
2 ms |
3568 KB |
Output is correct |
32 |
Correct |
2 ms |
3568 KB |
Output is correct |