# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
52810 |
2018-06-26T20:07:17 Z |
zadrga |
Gap (APIO16_gap) |
C++14 |
|
105 ms |
6264 KB |
/*
Idea:
- https://codeforces.com/blog/entry/44657?#comment-293060
*/
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL * 1000 * 1000 * 1000 * 1000 * 1000 * 1000)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 100111
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
set<ll> s;
ll findGap(int T, int N){
if(T == 1){
ll l = 0, d = INF, x, y;
while(s.size() < N){
MinMax(l, d, &x, &y);
if(x != -1)
s.insert(x);
if(y != -1)
s.insert(y);
l = x + 1;
d = y - 1;
}
ll ans = -1;
for(auto it = s.begin(); next(it) != s.end(); it++)
ans = max(ans, *next(it) - *it);
return ans;
}
if(T == 2){
ll l = 0, d = INF, x, y, a, b;
MinMax(l, d, &x, &y);
if(N == 2)
return y - x;
ll dist = ((y - x) + (N - 2) - 1) / (N - 2);
for(ll i = x; i <= y; i += dist){
MinMax(i, i + dist - 1, &a, &b);
if(a != -1)
s.insert(a);
if(b != -1)
s.insert(b);
}
ll ans = -1;
for(auto it = s.begin(); next(it) != s.end(); it++)
ans = max(ans, *next(it) - *it);
return ans;
}
}
Compilation message
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:28:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(s.size() < N){
~~~~~~~~~^~~
gap.cpp:70:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
560 KB |
Output is correct |
4 |
Correct |
2 ms |
560 KB |
Output is correct |
5 |
Correct |
2 ms |
560 KB |
Output is correct |
6 |
Correct |
2 ms |
560 KB |
Output is correct |
7 |
Correct |
3 ms |
560 KB |
Output is correct |
8 |
Correct |
2 ms |
572 KB |
Output is correct |
9 |
Correct |
2 ms |
572 KB |
Output is correct |
10 |
Correct |
2 ms |
572 KB |
Output is correct |
11 |
Correct |
4 ms |
572 KB |
Output is correct |
12 |
Correct |
4 ms |
576 KB |
Output is correct |
13 |
Correct |
4 ms |
576 KB |
Output is correct |
14 |
Correct |
3 ms |
576 KB |
Output is correct |
15 |
Correct |
2 ms |
576 KB |
Output is correct |
16 |
Correct |
20 ms |
1980 KB |
Output is correct |
17 |
Correct |
21 ms |
1980 KB |
Output is correct |
18 |
Correct |
21 ms |
1980 KB |
Output is correct |
19 |
Correct |
21 ms |
1980 KB |
Output is correct |
20 |
Correct |
17 ms |
2024 KB |
Output is correct |
21 |
Correct |
89 ms |
6120 KB |
Output is correct |
22 |
Correct |
102 ms |
6120 KB |
Output is correct |
23 |
Correct |
87 ms |
6120 KB |
Output is correct |
24 |
Correct |
88 ms |
6120 KB |
Output is correct |
25 |
Correct |
78 ms |
6120 KB |
Output is correct |
26 |
Correct |
84 ms |
6120 KB |
Output is correct |
27 |
Correct |
86 ms |
6120 KB |
Output is correct |
28 |
Correct |
93 ms |
6120 KB |
Output is correct |
29 |
Correct |
86 ms |
6120 KB |
Output is correct |
30 |
Correct |
70 ms |
6120 KB |
Output is correct |
31 |
Correct |
2 ms |
6120 KB |
Output is correct |
32 |
Correct |
2 ms |
6120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6120 KB |
Output is correct |
2 |
Correct |
2 ms |
6120 KB |
Output is correct |
3 |
Correct |
2 ms |
6120 KB |
Output is correct |
4 |
Correct |
2 ms |
6120 KB |
Output is correct |
5 |
Correct |
2 ms |
6120 KB |
Output is correct |
6 |
Correct |
2 ms |
6120 KB |
Output is correct |
7 |
Correct |
2 ms |
6120 KB |
Output is correct |
8 |
Correct |
2 ms |
6120 KB |
Output is correct |
9 |
Correct |
2 ms |
6120 KB |
Output is correct |
10 |
Correct |
2 ms |
6120 KB |
Output is correct |
11 |
Correct |
4 ms |
6120 KB |
Output is correct |
12 |
Correct |
4 ms |
6120 KB |
Output is correct |
13 |
Correct |
3 ms |
6120 KB |
Output is correct |
14 |
Correct |
3 ms |
6120 KB |
Output is correct |
15 |
Correct |
3 ms |
6120 KB |
Output is correct |
16 |
Correct |
24 ms |
6120 KB |
Output is correct |
17 |
Correct |
24 ms |
6120 KB |
Output is correct |
18 |
Correct |
24 ms |
6120 KB |
Output is correct |
19 |
Correct |
24 ms |
6120 KB |
Output is correct |
20 |
Correct |
10 ms |
6120 KB |
Output is correct |
21 |
Correct |
101 ms |
6120 KB |
Output is correct |
22 |
Correct |
100 ms |
6120 KB |
Output is correct |
23 |
Correct |
101 ms |
6120 KB |
Output is correct |
24 |
Correct |
100 ms |
6120 KB |
Output is correct |
25 |
Correct |
105 ms |
6264 KB |
Output is correct |
26 |
Correct |
103 ms |
6264 KB |
Output is correct |
27 |
Correct |
101 ms |
6264 KB |
Output is correct |
28 |
Correct |
100 ms |
6264 KB |
Output is correct |
29 |
Correct |
101 ms |
6264 KB |
Output is correct |
30 |
Correct |
42 ms |
6264 KB |
Output is correct |
31 |
Correct |
2 ms |
6264 KB |
Output is correct |
32 |
Correct |
2 ms |
6264 KB |
Output is correct |