# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
564882 |
2022-05-19T22:13:19 Z |
ljuba |
Gap (APIO16_gap) |
C++17 |
|
1587 ms |
9840 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long findGap(int T, int N) //probably again different solution for different test cases :(
{
if(T == 1) {
// cerr << "entered?" << endl;
vector<ll> v(N);
ll mini = -1, maksi = ll(1e18) + 1;
for(int i = 0; i < N; ++i) {
if(i > N - i - 1) break;
++mini, --maksi;
MinMax(mini, maksi, &mini, &maksi);
// cerr << mini << " " << maksi << '\n';
v[i] = mini;
v[N - i - 1] = maksi;
}
ll ans = 0;
for(int i = 1; i < N; ++i) {
ans = max(ans, v[i] - v[i - 1]);
}
return ans;
} else {
ll mini = 0, maksi = ll(1e18);
MinMax(mini, maksi, &mini, &maksi);
ll korak = (maksi - mini + N - 2) / (N - 1);
ll prosli = mini;
ll ans = 0;
ll naj = maksi;
for(ll i = mini + 1; i <= naj; i += korak + 1) {
MinMax(i, min(i + korak, naj), &mini, &maksi);
cerr << "----------" << endl;
cerr << i << " " << i + korak << endl;
cerr << mini << " " << maksi << endl;
cerr << "----------" << endl;
if(mini != -1) {
ans = max(ans, mini - prosli);
prosli = maksi;
}
}
return ans;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
272 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
11 ms |
720 KB |
Output is correct |
17 |
Correct |
11 ms |
720 KB |
Output is correct |
18 |
Correct |
10 ms |
684 KB |
Output is correct |
19 |
Correct |
10 ms |
688 KB |
Output is correct |
20 |
Correct |
7 ms |
592 KB |
Output is correct |
21 |
Correct |
49 ms |
1828 KB |
Output is correct |
22 |
Correct |
36 ms |
1828 KB |
Output is correct |
23 |
Correct |
48 ms |
1864 KB |
Output is correct |
24 |
Correct |
40 ms |
1760 KB |
Output is correct |
25 |
Correct |
33 ms |
1832 KB |
Output is correct |
26 |
Correct |
44 ms |
1828 KB |
Output is correct |
27 |
Correct |
45 ms |
1864 KB |
Output is correct |
28 |
Correct |
43 ms |
1856 KB |
Output is correct |
29 |
Correct |
40 ms |
1856 KB |
Output is correct |
30 |
Correct |
33 ms |
1832 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
2 ms |
336 KB |
Output is correct |
8 |
Correct |
2 ms |
336 KB |
Output is correct |
9 |
Correct |
2 ms |
336 KB |
Output is correct |
10 |
Correct |
2 ms |
208 KB |
Output is correct |
11 |
Correct |
25 ms |
424 KB |
Output is correct |
12 |
Correct |
24 ms |
372 KB |
Output is correct |
13 |
Correct |
24 ms |
444 KB |
Output is correct |
14 |
Correct |
22 ms |
400 KB |
Output is correct |
15 |
Correct |
25 ms |
336 KB |
Output is correct |
16 |
Correct |
392 ms |
2608 KB |
Output is correct |
17 |
Correct |
358 ms |
2604 KB |
Output is correct |
18 |
Correct |
374 ms |
2664 KB |
Output is correct |
19 |
Correct |
376 ms |
2604 KB |
Output is correct |
20 |
Correct |
364 ms |
1428 KB |
Output is correct |
21 |
Correct |
1502 ms |
9680 KB |
Output is correct |
22 |
Correct |
1459 ms |
9780 KB |
Output is correct |
23 |
Correct |
1548 ms |
9840 KB |
Output is correct |
24 |
Correct |
1515 ms |
9692 KB |
Output is correct |
25 |
Correct |
1495 ms |
8308 KB |
Output is correct |
26 |
Correct |
1442 ms |
9684 KB |
Output is correct |
27 |
Correct |
1587 ms |
9744 KB |
Output is correct |
28 |
Correct |
1507 ms |
9636 KB |
Output is correct |
29 |
Correct |
1535 ms |
9688 KB |
Output is correct |
30 |
Correct |
1296 ms |
4884 KB |
Output is correct |
31 |
Correct |
3 ms |
336 KB |
Output is correct |
32 |
Correct |
2 ms |
336 KB |
Output is correct |