# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
960036 |
2024-04-09T14:50:54 Z |
kim |
Gap (APIO16_gap) |
C++17 |
|
40 ms |
4252 KB |
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define eb emplace_back
long long findGap(int T, int N)
{
if(T==1){
ll a=1,b=1e18;
vector<ll> vec;
for(int i=0;i<N+1>>1;++i){
MinMax(a,b,&a,&b);
if(a==b) vec.eb(a);
else vec.eb(a++), vec.eb(b--);
}
sort(vec.begin(),vec.end());
ll ans=0;
for(int i=1;i<vec.size();++i) ans=max(ans,vec[i]-vec[i-1]);
return ans;
}
ll a,b,c,d;
MinMax(1,1e18,&a,&b);
if(N==2) return b-a;
ll ans=(b-a+N-2)/(N-1);
while(a+ans<b){
MinMax(a+1,a+ans,&c,&d);
if(d!=-1) a=d;
else{
MinMax(a+1,b-1,&c,&d);
if(d!=-1){
ans=max(c-a,b-d);
a=c;
b=d;
}
else{
ans=b-a;
break;
}
}
}
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:12:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
12 | for(int i=0;i<N+1>>1;++i){
| ~^~
gap.cpp:19:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
19 | for(int i=1;i<vec.size();++i) ans=max(ans,vec[i]-vec[i-1]);
| ~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
596 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
0 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 |
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 |
2 ms |
2552 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
9 ms |
2836 KB |
Output is correct |
17 |
Correct |
9 ms |
2848 KB |
Output is correct |
18 |
Correct |
9 ms |
3088 KB |
Output is correct |
19 |
Correct |
8 ms |
2840 KB |
Output is correct |
20 |
Correct |
7 ms |
2996 KB |
Output is correct |
21 |
Correct |
32 ms |
4152 KB |
Output is correct |
22 |
Correct |
32 ms |
4152 KB |
Output is correct |
23 |
Correct |
32 ms |
4032 KB |
Output is correct |
24 |
Correct |
35 ms |
3972 KB |
Output is correct |
25 |
Correct |
29 ms |
4252 KB |
Output is correct |
26 |
Correct |
40 ms |
3908 KB |
Output is correct |
27 |
Correct |
32 ms |
3992 KB |
Output is correct |
28 |
Correct |
32 ms |
3848 KB |
Output is correct |
29 |
Correct |
35 ms |
3768 KB |
Output is correct |
30 |
Correct |
29 ms |
4200 KB |
Output is correct |
31 |
Correct |
1 ms |
2392 KB |
Output is correct |
32 |
Correct |
1 ms |
2644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Partially correct |
1 ms |
2644 KB |
Partially correct |
3 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
4 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
7 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
8 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
9 |
Partially correct |
1 ms |
2644 KB |
Partially correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
12 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
13 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
14 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Partially correct |
7 ms |
2580 KB |
Partially correct |
17 |
Partially correct |
5 ms |
2580 KB |
Partially correct |
18 |
Partially correct |
5 ms |
2576 KB |
Partially correct |
19 |
Partially correct |
6 ms |
2560 KB |
Partially correct |
20 |
Correct |
2 ms |
2548 KB |
Output is correct |
21 |
Partially correct |
17 ms |
2852 KB |
Partially correct |
22 |
Partially correct |
17 ms |
2852 KB |
Partially correct |
23 |
Partially correct |
21 ms |
2840 KB |
Partially correct |
24 |
Partially correct |
17 ms |
3012 KB |
Partially correct |
25 |
Correct |
39 ms |
3012 KB |
Output is correct |
26 |
Partially correct |
17 ms |
2848 KB |
Partially correct |
27 |
Partially correct |
17 ms |
2856 KB |
Partially correct |
28 |
Partially correct |
18 ms |
2852 KB |
Partially correct |
29 |
Partially correct |
21 ms |
2924 KB |
Partially correct |
30 |
Correct |
9 ms |
2860 KB |
Output is correct |
31 |
Correct |
1 ms |
2396 KB |
Output is correct |
32 |
Correct |
1 ms |
2392 KB |
Output is correct |