# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
954750 |
2024-03-28T13:44:02 Z |
Itamar |
Gap (APIO16_gap) |
C++14 |
|
1193 ms |
524288 KB |
#include "gap.h"
using namespace std;
#define ll long long
#include <vector>
#define vll vector<ll>
#include <algorithm>
long long findGap(int T, int N)
{
if (T == 1) {
ll a = -1, b = 1e18 + 1;
vll v;
for (int it = 0; it < (N + 1) / 2; it++) {
auto *at = new ll, *bt = new ll;
MinMax(a + 1, b - 1, at, bt);
a = *at, b = *bt;
v.push_back(a); if(a!=b)v.push_back(b);
}
sort(v.begin(), v.end());
ll ans = 0;
for (int i = 0; i < v.size() - 1; i++)ans = max(ans, v[i + 1] - v[i]);
return ans;
}
else {
auto* a = new ll, * b = new ll;
MinMax(0, 1e18, a, b);
vll v;
ll d = (b - a + N - 2) / (N - 1);
for (int i = *a; i < *b; i += d + 1) {
auto *c = new ll, * k = new ll;
*c = 0, * k = 0;
MinMax(i, min(i + d,*b), c, k);
v.push_back(*c); v.push_back(*k);
}
sort(v.begin(), v.end());
ll ans = d;
for (int i = 0; i < v.size() - 1; i++) {
if (v[i] > -1) {
ans = max(ans, v[i + 1] - v[i]);
}
}
return ans;
}
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:20:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | for (int i = 0; i < v.size() - 1; i++)ans = max(ans, v[i + 1] - v[i]);
| ~~^~~~~~~~~~~~~~
gap.cpp:36:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | for (int i = 0; i < v.size() - 1; i++) {
| ~~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
2388 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
0 ms |
2392 KB |
Output is correct |
10 |
Correct |
0 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2388 KB |
Output is correct |
12 |
Correct |
1 ms |
2644 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
2 ms |
2392 KB |
Output is correct |
16 |
Correct |
9 ms |
3460 KB |
Output is correct |
17 |
Correct |
9 ms |
3464 KB |
Output is correct |
18 |
Correct |
9 ms |
3464 KB |
Output is correct |
19 |
Correct |
8 ms |
3464 KB |
Output is correct |
20 |
Correct |
7 ms |
3448 KB |
Output is correct |
21 |
Correct |
33 ms |
6552 KB |
Output is correct |
22 |
Correct |
33 ms |
6556 KB |
Output is correct |
23 |
Correct |
33 ms |
6552 KB |
Output is correct |
24 |
Correct |
34 ms |
6756 KB |
Output is correct |
25 |
Correct |
30 ms |
6776 KB |
Output is correct |
26 |
Correct |
33 ms |
6556 KB |
Output is correct |
27 |
Correct |
35 ms |
6804 KB |
Output is correct |
28 |
Correct |
39 ms |
6616 KB |
Output is correct |
29 |
Correct |
36 ms |
6560 KB |
Output is correct |
30 |
Correct |
28 ms |
6800 KB |
Output is correct |
31 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
32 |
Correct |
2 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
494 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Runtime error |
547 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Runtime error |
526 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Runtime error |
572 ms |
524288 KB |
Execution killed with signal 9 |
5 |
Runtime error |
563 ms |
524288 KB |
Execution killed with signal 9 |
6 |
Runtime error |
574 ms |
524288 KB |
Execution killed with signal 9 |
7 |
Runtime error |
584 ms |
524288 KB |
Execution killed with signal 9 |
8 |
Runtime error |
576 ms |
524288 KB |
Execution killed with signal 9 |
9 |
Runtime error |
586 ms |
524288 KB |
Execution killed with signal 9 |
10 |
Partially correct |
67 ms |
40472 KB |
Partially correct |
11 |
Runtime error |
771 ms |
524288 KB |
Execution killed with signal 9 |
12 |
Runtime error |
773 ms |
524288 KB |
Execution killed with signal 9 |
13 |
Runtime error |
747 ms |
524288 KB |
Execution killed with signal 9 |
14 |
Runtime error |
752 ms |
524288 KB |
Execution killed with signal 9 |
15 |
Runtime error |
785 ms |
524288 KB |
Execution killed with signal 9 |
16 |
Runtime error |
1117 ms |
524288 KB |
Execution killed with signal 9 |
17 |
Runtime error |
962 ms |
524288 KB |
Execution killed with signal 9 |
18 |
Runtime error |
966 ms |
524288 KB |
Execution killed with signal 9 |
19 |
Runtime error |
965 ms |
524288 KB |
Execution killed with signal 9 |
20 |
Partially correct |
100 ms |
41300 KB |
Partially correct |
21 |
Runtime error |
1118 ms |
524288 KB |
Execution killed with signal 9 |
22 |
Runtime error |
1155 ms |
524288 KB |
Execution killed with signal 9 |
23 |
Runtime error |
1125 ms |
524288 KB |
Execution killed with signal 9 |
24 |
Runtime error |
1127 ms |
524288 KB |
Execution killed with signal 9 |
25 |
Runtime error |
1143 ms |
524288 KB |
Execution killed with signal 9 |
26 |
Runtime error |
1152 ms |
524288 KB |
Execution killed with signal 9 |
27 |
Runtime error |
1110 ms |
524288 KB |
Execution killed with signal 9 |
28 |
Runtime error |
1117 ms |
524288 KB |
Execution killed with signal 9 |
29 |
Runtime error |
1193 ms |
524288 KB |
Execution killed with signal 9 |
30 |
Partially correct |
140 ms |
53352 KB |
Partially correct |
31 |
Runtime error |
742 ms |
524288 KB |
Execution killed with signal 9 |
32 |
Runtime error |
655 ms |
524288 KB |
Execution killed with signal 9 |