# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
96034 |
2019-02-05T10:18:16 Z |
lyc |
Gap (APIO16_gap) |
C++14 |
|
63 ms |
4452 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long findGap(int T, int N)
{
ll ans = 0;
ll s, t, mn, mx;
if (T == 1) {
s = 0, t = (ll)1e18;
ll arr[N];
for (int i = 0; i < (N+1)/2; ++i) {
MinMax(s, t, &mn, &mx);
arr[i] = mn;
arr[N-1-i] = mx;
s = mn+1;
t = mx-1;
//cout << "FOUND " << mn << " " << mx << '\n';
}
//for (int i = 0; i < N; ++i) cout << arr[i] << ' ' ;cout << endl;
for (int i = 1; i < N; ++i) {
ans = max(ans, arr[i]-arr[i-1]);
}
}
else {
s = 0, t = (ll)1e18;
vector<ll> v;
MinMax(s, t, &mn, &mx);
s = mn, t = mx;
v.push_back(s);
ll mingap = (mx-mn+N-2)/(N-1);
for (ll x = s+1; x < t; x = x+mingap+1) {
MinMax(x, x+mingap, &mn, &mx);
//cout << "CALL " << x << " " << x+mingap << ":: " << mn << " " << mx << endl;
if (mn != -1) {
v.push_back(mn);
v.push_back(mx);
}
}
v.push_back(t);
//for (auto x : v) cout << x << ' ' ; cout << endl;
for (int i = 1; i < v.size(); ++i) {
ans = max(ans, v[i]-v[i-1]);
}
}
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:47:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 1; i < v.size(); ++i) {
~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
380 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
13 ms |
1116 KB |
Output is correct |
17 |
Correct |
13 ms |
1144 KB |
Output is correct |
18 |
Correct |
13 ms |
1144 KB |
Output is correct |
19 |
Correct |
13 ms |
1144 KB |
Output is correct |
20 |
Correct |
10 ms |
760 KB |
Output is correct |
21 |
Correct |
46 ms |
3576 KB |
Output is correct |
22 |
Correct |
47 ms |
3548 KB |
Output is correct |
23 |
Correct |
45 ms |
3576 KB |
Output is correct |
24 |
Correct |
47 ms |
3704 KB |
Output is correct |
25 |
Correct |
39 ms |
3036 KB |
Output is correct |
26 |
Correct |
46 ms |
3704 KB |
Output is correct |
27 |
Correct |
46 ms |
3704 KB |
Output is correct |
28 |
Correct |
47 ms |
3640 KB |
Output is correct |
29 |
Correct |
46 ms |
3704 KB |
Output is correct |
30 |
Correct |
35 ms |
2424 KB |
Output is correct |
31 |
Correct |
2 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
296 KB |
Output is correct |
# |
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 |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
388 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
17 ms |
1400 KB |
Output is correct |
17 |
Correct |
17 ms |
1272 KB |
Output is correct |
18 |
Correct |
17 ms |
1272 KB |
Output is correct |
19 |
Correct |
16 ms |
1284 KB |
Output is correct |
20 |
Correct |
8 ms |
636 KB |
Output is correct |
21 |
Correct |
62 ms |
4080 KB |
Output is correct |
22 |
Correct |
62 ms |
3956 KB |
Output is correct |
23 |
Correct |
63 ms |
4112 KB |
Output is correct |
24 |
Correct |
61 ms |
4052 KB |
Output is correct |
25 |
Correct |
58 ms |
4452 KB |
Output is correct |
26 |
Correct |
63 ms |
4080 KB |
Output is correct |
27 |
Correct |
61 ms |
4040 KB |
Output is correct |
28 |
Correct |
62 ms |
3956 KB |
Output is correct |
29 |
Correct |
63 ms |
4104 KB |
Output is correct |
30 |
Correct |
30 ms |
2040 KB |
Output is correct |
31 |
Correct |
2 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
376 KB |
Output is correct |