# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
39807 |
2018-01-19T08:18:58 Z |
14kg |
Gap (APIO16_gap) |
C++11 |
|
95 ms |
9052 KB |
#include "gap.h"
#include <set>
#define NUM_MAX 1000000000000000000
#define max2(x,y) (x>y?x:y)
using namespace std;
int n;
set<long long> S;
long long f1() {
long long l = 0, r = NUM_MAX;
long long t1, t2, res = 0;
while (l <= r) {
MinMax(l, r, &t1, &t2);
if (t1 < 0) break;
S.insert(l = t1), S.insert(r = t2);
l++, r--;
if (S.size() == n) break;
}
t1 = NUM_MAX;
for (auto i : S) res = max2(res, i - t1), t1 = i;
return res;
}
long long f2() {
long long S, E, len, res, t1, t2, path = NUM_MAX;
MinMax(0, NUM_MAX, &S, &E);
res = len = (E - S) / (n - 1) + ((E - S) % (n - 1) ? 1 : 0);
for (long long s = S; s + len <= E; s += len) {
MinMax(s, s + len - 1, &t1, &t2);
if (t1 < 0) continue;
res = max2(res, t1 - path), path = t2;
} res = max2(res, E - path);
return res;
}
long long findGap(int T, int _n) {
n = _n;
if (T == 1) return f1();
else return f2();
}
Compilation message
gap.cpp: In function 'long long int f1()':
gap.cpp:20:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (S.size() == n) break;
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4300 KB |
Output is correct |
2 |
Correct |
0 ms |
4300 KB |
Output is correct |
3 |
Correct |
0 ms |
4300 KB |
Output is correct |
4 |
Correct |
0 ms |
4300 KB |
Output is correct |
5 |
Correct |
0 ms |
4300 KB |
Output is correct |
6 |
Correct |
0 ms |
4300 KB |
Output is correct |
7 |
Correct |
0 ms |
4300 KB |
Output is correct |
8 |
Correct |
0 ms |
4300 KB |
Output is correct |
9 |
Correct |
0 ms |
4300 KB |
Output is correct |
10 |
Correct |
0 ms |
4300 KB |
Output is correct |
11 |
Correct |
1 ms |
4432 KB |
Output is correct |
12 |
Correct |
1 ms |
4432 KB |
Output is correct |
13 |
Correct |
2 ms |
4432 KB |
Output is correct |
14 |
Correct |
1 ms |
4432 KB |
Output is correct |
15 |
Correct |
1 ms |
4432 KB |
Output is correct |
16 |
Correct |
21 ms |
5488 KB |
Output is correct |
17 |
Correct |
17 ms |
5488 KB |
Output is correct |
18 |
Correct |
11 ms |
5488 KB |
Output is correct |
19 |
Correct |
18 ms |
5488 KB |
Output is correct |
20 |
Correct |
9 ms |
5488 KB |
Output is correct |
21 |
Correct |
83 ms |
9052 KB |
Output is correct |
22 |
Correct |
84 ms |
9052 KB |
Output is correct |
23 |
Correct |
82 ms |
9052 KB |
Output is correct |
24 |
Correct |
89 ms |
9052 KB |
Output is correct |
25 |
Correct |
75 ms |
9052 KB |
Output is correct |
26 |
Correct |
88 ms |
9052 KB |
Output is correct |
27 |
Correct |
84 ms |
9052 KB |
Output is correct |
28 |
Correct |
89 ms |
9052 KB |
Output is correct |
29 |
Correct |
92 ms |
9052 KB |
Output is correct |
30 |
Correct |
85 ms |
9052 KB |
Output is correct |
31 |
Correct |
0 ms |
4300 KB |
Output is correct |
32 |
Correct |
0 ms |
4300 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4300 KB |
Output is correct |
2 |
Correct |
0 ms |
4300 KB |
Output is correct |
3 |
Correct |
0 ms |
4300 KB |
Output is correct |
4 |
Correct |
0 ms |
4300 KB |
Output is correct |
5 |
Correct |
0 ms |
4300 KB |
Output is correct |
6 |
Correct |
0 ms |
4300 KB |
Output is correct |
7 |
Correct |
0 ms |
4300 KB |
Output is correct |
8 |
Correct |
0 ms |
4300 KB |
Output is correct |
9 |
Correct |
0 ms |
4300 KB |
Output is correct |
10 |
Incorrect |
0 ms |
4300 KB |
Output isn't correct |
11 |
Correct |
1 ms |
4300 KB |
Output is correct |
12 |
Correct |
1 ms |
4300 KB |
Output is correct |
13 |
Correct |
1 ms |
4300 KB |
Output is correct |
14 |
Correct |
0 ms |
4300 KB |
Output is correct |
15 |
Correct |
1 ms |
4300 KB |
Output is correct |
16 |
Correct |
20 ms |
4300 KB |
Output is correct |
17 |
Correct |
19 ms |
4300 KB |
Output is correct |
18 |
Correct |
18 ms |
4300 KB |
Output is correct |
19 |
Correct |
19 ms |
4300 KB |
Output is correct |
20 |
Correct |
8 ms |
4300 KB |
Output is correct |
21 |
Correct |
75 ms |
4300 KB |
Output is correct |
22 |
Correct |
95 ms |
4300 KB |
Output is correct |
23 |
Correct |
71 ms |
4300 KB |
Output is correct |
24 |
Correct |
68 ms |
4300 KB |
Output is correct |
25 |
Correct |
68 ms |
4300 KB |
Output is correct |
26 |
Correct |
81 ms |
4300 KB |
Output is correct |
27 |
Correct |
79 ms |
4300 KB |
Output is correct |
28 |
Correct |
74 ms |
4300 KB |
Output is correct |
29 |
Correct |
66 ms |
4300 KB |
Output is correct |
30 |
Correct |
40 ms |
4300 KB |
Output is correct |
31 |
Correct |
0 ms |
4300 KB |
Output is correct |
32 |
Correct |
0 ms |
4300 KB |
Output is correct |