# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
960085 |
2024-04-09T15:46:55 Z |
kim |
Gap (APIO16_gap) |
C++17 |
|
37 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);
for(ll i=a+ans;i-ans<=b;i+=ans){
MinMax(a+1,i,&c,&d);
if(c==-1) continue;
ans=max(ans,c-a);
a=d;
}
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 |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 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 |
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 |
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 |
2 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 |
2388 KB |
Output is correct |
16 |
Correct |
10 ms |
2888 KB |
Output is correct |
17 |
Correct |
9 ms |
2928 KB |
Output is correct |
18 |
Correct |
8 ms |
2828 KB |
Output is correct |
19 |
Correct |
9 ms |
2852 KB |
Output is correct |
20 |
Correct |
7 ms |
2984 KB |
Output is correct |
21 |
Correct |
32 ms |
3948 KB |
Output is correct |
22 |
Correct |
32 ms |
3996 KB |
Output is correct |
23 |
Correct |
34 ms |
3916 KB |
Output is correct |
24 |
Correct |
32 ms |
4252 KB |
Output is correct |
25 |
Correct |
34 ms |
3988 KB |
Output is correct |
26 |
Correct |
32 ms |
3904 KB |
Output is correct |
27 |
Correct |
32 ms |
3992 KB |
Output is correct |
28 |
Correct |
31 ms |
3972 KB |
Output is correct |
29 |
Correct |
35 ms |
3872 KB |
Output is correct |
30 |
Correct |
27 ms |
3996 KB |
Output is correct |
31 |
Correct |
1 ms |
2392 KB |
Output is correct |
32 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2400 KB |
Output is correct |
4 |
Correct |
0 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2400 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2400 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 |
2400 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2400 KB |
Output is correct |
14 |
Correct |
1 ms |
2644 KB |
Output is correct |
15 |
Correct |
1 ms |
2548 KB |
Output is correct |
16 |
Correct |
5 ms |
2584 KB |
Output is correct |
17 |
Correct |
7 ms |
2844 KB |
Output is correct |
18 |
Correct |
4 ms |
2584 KB |
Output is correct |
19 |
Correct |
5 ms |
2588 KB |
Output is correct |
20 |
Correct |
3 ms |
2572 KB |
Output is correct |
21 |
Correct |
16 ms |
2852 KB |
Output is correct |
22 |
Correct |
21 ms |
2852 KB |
Output is correct |
23 |
Correct |
22 ms |
2848 KB |
Output is correct |
24 |
Correct |
18 ms |
2852 KB |
Output is correct |
25 |
Correct |
37 ms |
2848 KB |
Output is correct |
26 |
Correct |
17 ms |
2852 KB |
Output is correct |
27 |
Correct |
17 ms |
2856 KB |
Output is correct |
28 |
Correct |
17 ms |
2856 KB |
Output is correct |
29 |
Correct |
17 ms |
3012 KB |
Output is correct |
30 |
Correct |
14 ms |
2844 KB |
Output is correct |
31 |
Correct |
1 ms |
2392 KB |
Output is correct |
32 |
Correct |
1 ms |
2644 KB |
Output is correct |