# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
888320 |
2023-12-17T00:42:42 Z |
12345678 |
Gap (APIO16_gap) |
C++17 |
|
2000 ms |
8848 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
long long findGap(int T, int N)
{
if (T==1)
{
ll x=0, y=1e18, a, b, idx=0, mx=0;
vector<ll> v;
while (v.size()<N)
{
MinMax(x, y, &a, &b);
if (a==b) v.push_back(a);
else v.push_back(a), v.push_back(b);
x=a+1; y=b-1;
}
sort(v.begin(), v.end());
for (int i=1; i<v.size(); i++) mx=max(mx, v[i]-v[i-1]);
return mx;
}
else
{
ll x=0, y=1e18, mn, mx, mmn, mmx, res=0;
vector<ll> v;
MinMax(x, y, &mmn, &mmx);
if (mmx-mmn+1<N+1) return 1;
ll gap=(mmx-mmn+1)/(N+1);
for (int i=mmn; i<=mmx; i+=gap)
{
MinMax(i, i+gap-1, &mn, &mx);
if (mn==-1) continue;
v.push_back(mn);
if (mn!=mx) v.push_back(mx);
if (v.size()>2*N) cout<<1/0;
}
sort(v.begin(), v.end());
for (int i=1; i<v.size(); i++) res=max(res, v[i]-v[i-1]);
return res;
}
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:15:24: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
15 | while (v.size()<N)
| ~~~~~~~~^~
gap.cpp:23:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for (int i=1; i<v.size(); i++) mx=max(mx, v[i]-v[i-1]);
| ~^~~~~~~~~
gap.cpp:13:31: warning: unused variable 'idx' [-Wunused-variable]
13 | ll x=0, y=1e18, a, b, idx=0, mx=0;
| ^~~
gap.cpp:39:25: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
39 | if (v.size()>2*N) cout<<1/0;
| ~~~~~~~~^~~~
gap.cpp:39:38: warning: division by zero [-Wdiv-by-zero]
39 | if (v.size()>2*N) cout<<1/0;
| ~^~
gap.cpp:42:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 | for (int i=1; i<v.size(); i++) res=max(res, v[i]-v[i-1]);
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2392 KB |
Output is correct |
4 |
Correct |
0 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2392 KB |
Output is correct |
6 |
Correct |
0 ms |
2392 KB |
Output is correct |
7 |
Correct |
0 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
8 ms |
2992 KB |
Output is correct |
17 |
Correct |
8 ms |
2844 KB |
Output is correct |
18 |
Correct |
8 ms |
2844 KB |
Output is correct |
19 |
Correct |
8 ms |
2840 KB |
Output is correct |
20 |
Correct |
7 ms |
2904 KB |
Output is correct |
21 |
Correct |
32 ms |
3904 KB |
Output is correct |
22 |
Correct |
36 ms |
3992 KB |
Output is correct |
23 |
Correct |
32 ms |
3996 KB |
Output is correct |
24 |
Correct |
33 ms |
4000 KB |
Output is correct |
25 |
Correct |
29 ms |
3992 KB |
Output is correct |
26 |
Correct |
32 ms |
3988 KB |
Output is correct |
27 |
Correct |
32 ms |
3992 KB |
Output is correct |
28 |
Correct |
32 ms |
4164 KB |
Output is correct |
29 |
Correct |
31 ms |
3996 KB |
Output is correct |
30 |
Correct |
27 ms |
3984 KB |
Output is correct |
31 |
Correct |
0 ms |
2392 KB |
Output is correct |
32 |
Correct |
0 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
4696 KB |
Execution killed with signal 8 |
2 |
Execution timed out |
3085 ms |
2392 KB |
Time limit exceeded |
3 |
Execution timed out |
3041 ms |
2392 KB |
Time limit exceeded |
4 |
Execution timed out |
3057 ms |
2392 KB |
Time limit exceeded |
5 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
6 |
Runtime error |
2 ms |
4696 KB |
Execution killed with signal 8 |
7 |
Runtime error |
2 ms |
4696 KB |
Execution killed with signal 8 |
8 |
Execution timed out |
3088 ms |
2392 KB |
Time limit exceeded |
9 |
Runtime error |
2 ms |
4696 KB |
Execution killed with signal 8 |
10 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
11 |
Execution timed out |
3095 ms |
2392 KB |
Time limit exceeded |
12 |
Runtime error |
3 ms |
4696 KB |
Execution killed with signal 8 |
13 |
Runtime error |
3 ms |
4696 KB |
Execution killed with signal 8 |
14 |
Runtime error |
3 ms |
4692 KB |
Execution killed with signal 8 |
15 |
Runtime error |
3 ms |
4868 KB |
Execution killed with signal 8 |
16 |
Execution timed out |
3080 ms |
2584 KB |
Time limit exceeded |
17 |
Execution timed out |
3050 ms |
2576 KB |
Time limit exceeded |
18 |
Execution timed out |
3082 ms |
2580 KB |
Time limit exceeded |
19 |
Execution timed out |
3021 ms |
2580 KB |
Time limit exceeded |
20 |
Partially correct |
5 ms |
2576 KB |
Partially correct |
21 |
Runtime error |
29 ms |
8768 KB |
Execution killed with signal 8 |
22 |
Execution timed out |
3062 ms |
2852 KB |
Time limit exceeded |
23 |
Execution timed out |
3054 ms |
2852 KB |
Time limit exceeded |
24 |
Runtime error |
28 ms |
8844 KB |
Execution killed with signal 8 |
25 |
Runtime error |
86 ms |
8840 KB |
Execution killed with signal 8 |
26 |
Runtime error |
39 ms |
8848 KB |
Execution killed with signal 8 |
27 |
Runtime error |
39 ms |
8844 KB |
Execution killed with signal 8 |
28 |
Runtime error |
39 ms |
8840 KB |
Execution killed with signal 8 |
29 |
Execution timed out |
3016 ms |
3096 KB |
Time limit exceeded |
30 |
Partially correct |
23 ms |
3104 KB |
Partially correct |
31 |
Runtime error |
2 ms |
4696 KB |
Execution killed with signal 8 |
32 |
Runtime error |
3 ms |
4696 KB |
Execution killed with signal 8 |