# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
590914 |
2022-07-06T14:09:43 Z |
MasterTaster |
Gap (APIO16_gap) |
C++14 |
|
2000 ms |
1736 KB |
#include "gap.h"
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define xx first
#define yy second
#define MAXN 100010
using namespace std;
vector<int> svi;
long long findGap(int t, int n)
{
if (t==1)
{
ll minn, maxx;
MinMax(0LL, 1000000000000000000LL, &minn, &maxx);
if (n==2) { return maxx-minn; }
int i=1; int j=n-2;
ll ress=0;
while (i<=j)
{
ll staromin=minn, staromax=maxx;
MinMax(minn+1, maxx-1, &minn, &maxx);
if (j-i==1) { ress=max(ress, maxx-minn); }
ress=max(ress, max(minn-staromin, staromax-maxx));
i++; j--;
}
return ress;
}
else
{
ll minn, maxx;
MinMax(0LL, 1000000000000000000LL, &minn, &maxx);
int skok=(maxx-minn+n)/(n);
//cout<<minn<<" "<<maxx<<" "<<skok<<endl;
for (int i=minn; i<maxx; i+=skok)
{
ll a, b;
MinMax(i, min(maxx, (ll)i+skok), &a, &b);
//cout<<endl<<i<<" "<<min(maxx, (ll)i+skok-1)<<" "<<a<<" "<<b<<endl;
if (a==-1) { continue; }
else if (a!=b) { /*cout<<a<<" "<<b<<endl;*/ svi.pb(a); svi.pb(b); }
else { /*cout<<a<<endl;*/ svi.pb(a); }
}
ll ress=skok;
for (int i=0; i<svi.size()-1; i++) ress=max(ress, (ll)(svi[i+1]-svi[i]));
ress=max(ress, maxx-svi[svi.size()-1]);
return ress;
}
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:58:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | for (int i=0; i<svi.size()-1; i++) ress=max(ress, (ll)(svi[i+1]-svi[i]));
| ~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 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 |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 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 |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
9 ms |
476 KB |
Output is correct |
17 |
Correct |
9 ms |
464 KB |
Output is correct |
18 |
Correct |
11 ms |
464 KB |
Output is correct |
19 |
Correct |
12 ms |
476 KB |
Output is correct |
20 |
Correct |
7 ms |
508 KB |
Output is correct |
21 |
Correct |
35 ms |
992 KB |
Output is correct |
22 |
Correct |
36 ms |
1060 KB |
Output is correct |
23 |
Correct |
41 ms |
968 KB |
Output is correct |
24 |
Correct |
34 ms |
1084 KB |
Output is correct |
25 |
Correct |
33 ms |
992 KB |
Output is correct |
26 |
Correct |
34 ms |
1096 KB |
Output is correct |
27 |
Correct |
38 ms |
1080 KB |
Output is correct |
28 |
Correct |
37 ms |
1056 KB |
Output is correct |
29 |
Correct |
34 ms |
996 KB |
Output is correct |
30 |
Correct |
30 ms |
1104 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
208 KB |
Execution failed because the return code was nonzero |
2 |
Execution timed out |
3053 ms |
208 KB |
Time limit exceeded |
3 |
Runtime error |
0 ms |
208 KB |
Execution failed because the return code was nonzero |
4 |
Execution timed out |
3075 ms |
208 KB |
Time limit exceeded |
5 |
Partially correct |
0 ms |
208 KB |
Partially correct |
6 |
Execution timed out |
3073 ms |
208 KB |
Time limit exceeded |
7 |
Runtime error |
0 ms |
208 KB |
Execution failed because the return code was nonzero |
8 |
Runtime error |
0 ms |
208 KB |
Execution failed because the return code was nonzero |
9 |
Execution timed out |
3052 ms |
208 KB |
Time limit exceeded |
10 |
Partially correct |
0 ms |
208 KB |
Partially correct |
11 |
Runtime error |
1 ms |
208 KB |
Execution failed because the return code was nonzero |
12 |
Runtime error |
0 ms |
208 KB |
Execution failed because the return code was nonzero |
13 |
Execution timed out |
3066 ms |
208 KB |
Time limit exceeded |
14 |
Execution timed out |
3035 ms |
208 KB |
Time limit exceeded |
15 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
16 |
Execution timed out |
3048 ms |
464 KB |
Time limit exceeded |
17 |
Execution timed out |
3016 ms |
620 KB |
Time limit exceeded |
18 |
Execution timed out |
3054 ms |
492 KB |
Time limit exceeded |
19 |
Runtime error |
4 ms |
464 KB |
Execution failed because the return code was nonzero |
20 |
Partially correct |
6 ms |
520 KB |
Partially correct |
21 |
Execution timed out |
3052 ms |
1100 KB |
Time limit exceeded |
22 |
Execution timed out |
3042 ms |
1108 KB |
Time limit exceeded |
23 |
Execution timed out |
3067 ms |
1108 KB |
Time limit exceeded |
24 |
Execution timed out |
3059 ms |
1212 KB |
Time limit exceeded |
25 |
Incorrect |
48 ms |
1736 KB |
Output isn't correct |
26 |
Execution timed out |
3026 ms |
1200 KB |
Time limit exceeded |
27 |
Execution timed out |
3054 ms |
1108 KB |
Time limit exceeded |
28 |
Execution timed out |
3048 ms |
1100 KB |
Time limit exceeded |
29 |
Execution timed out |
3048 ms |
1092 KB |
Time limit exceeded |
30 |
Partially correct |
32 ms |
1224 KB |
Partially correct |
31 |
Execution timed out |
3082 ms |
208 KB |
Time limit exceeded |
32 |
Execution timed out |
3064 ms |
208 KB |
Time limit exceeded |