답안 #715451

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
715451 2023-03-26T18:40:22 Z study Gap (APIO16_gap) C++17
100 / 100
60 ms 2320 KB
#include <bits/stdc++.h>
#include "gap.h"
using ll = long long;
using namespace std;

long long findGap(int T, int N){
	if (T == 1 or N == 2){
		ll pmini = 0, pmaxi = 1e18+2;
		vector<ll> ans;
		for (int i=0; i<(N+1)/2; ++i){
			long long a,b;
			MinMax(pmini,pmaxi,&a,&b);
			ans.emplace_back(a);
			ans.emplace_back(b);
			pmini = a+1;
			pmaxi = b-1;
		}
		sort(ans.begin(),ans.end());
		ll res = 0;
		for (int i=1; i<ans.size(); ++i){
			res = max(res,ans[i]-ans[i-1]);
		}
		return res;
	}
	else{
		ll mini,maxi, MAX_VAL = 1e18;
		MinMax(0ll,MAX_VAL,&mini,&maxi);
		ll block_siz = (maxi-mini-1)/(N-1), prev = mini, ans = 0;
		for (ll i=mini+1; i<=maxi-1; i += block_siz+1){
			ll a,b;
			MinMax(i,i+block_siz,&a,&b);
			if (a != -1) ans = max(ans,a-prev);
			if (b != -1) prev = b;
		}
		return ans;
	}
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:20:18: 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=1; i<ans.size(); ++i){
      |                 ~^~~~~~~~~~~
# 결과 실행 시간 메모리 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 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 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 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 10 ms 848 KB Output is correct
17 Correct 11 ms 812 KB Output is correct
18 Correct 12 ms 848 KB Output is correct
19 Correct 13 ms 848 KB Output is correct
20 Correct 10 ms 848 KB Output is correct
21 Correct 51 ms 2204 KB Output is correct
22 Correct 41 ms 2252 KB Output is correct
23 Correct 44 ms 2320 KB Output is correct
24 Correct 49 ms 2136 KB Output is correct
25 Correct 38 ms 2244 KB Output is correct
26 Correct 50 ms 2188 KB Output is correct
27 Correct 42 ms 2240 KB Output is correct
28 Correct 46 ms 2204 KB Output is correct
29 Correct 40 ms 2168 KB Output is correct
30 Correct 34 ms 2256 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 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 1 ms 208 KB Output is correct
6 Correct 1 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 208 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 13 ms 508 KB Output is correct
17 Correct 12 ms 428 KB Output is correct
18 Correct 13 ms 636 KB Output is correct
19 Correct 13 ms 504 KB Output is correct
20 Correct 7 ms 464 KB Output is correct
21 Correct 55 ms 1004 KB Output is correct
22 Correct 49 ms 1052 KB Output is correct
23 Correct 60 ms 968 KB Output is correct
24 Correct 54 ms 1056 KB Output is correct
25 Correct 48 ms 1088 KB Output is correct
26 Correct 60 ms 1080 KB Output is correct
27 Correct 50 ms 968 KB Output is correct
28 Correct 51 ms 1080 KB Output is correct
29 Correct 53 ms 1056 KB Output is correct
30 Correct 29 ms 1088 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct