답안 #960076

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
960076 2024-04-09T15:42:21 Z kim Gap (APIO16_gap) C++17
30 / 100
33 ms 4036 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(int i=a+ans;i<=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 0 ms 2392 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Correct 1 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 2524 KB Output is correct
16 Correct 8 ms 2836 KB Output is correct
17 Correct 8 ms 2852 KB Output is correct
18 Correct 8 ms 2840 KB Output is correct
19 Correct 11 ms 2836 KB Output is correct
20 Correct 8 ms 2824 KB Output is correct
21 Correct 32 ms 4036 KB Output is correct
22 Correct 31 ms 3996 KB Output is correct
23 Correct 32 ms 3996 KB Output is correct
24 Correct 33 ms 3780 KB Output is correct
25 Correct 31 ms 3976 KB Output is correct
26 Correct 32 ms 3988 KB Output is correct
27 Correct 31 ms 3996 KB Output is correct
28 Correct 31 ms 3760 KB Output is correct
29 Correct 32 ms 3984 KB Output is correct
30 Correct 26 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 2392 KB Output is correct
2 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
3 Runtime error 0 ms 2392 KB Execution failed because the return code was nonzero
4 Runtime error 0 ms 2392 KB Execution failed because the return code was nonzero
5 Correct 0 ms 2392 KB Output is correct
6 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
7 Runtime error 1 ms 2480 KB Execution failed because the return code was nonzero
8 Runtime error 0 ms 2392 KB Execution failed because the return code was nonzero
9 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
10 Incorrect 0 ms 2392 KB Output isn't correct
11 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
12 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
13 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
14 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
15 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
16 Runtime error 5 ms 2580 KB Execution failed because the return code was nonzero
17 Runtime error 4 ms 2752 KB Execution failed because the return code was nonzero
18 Runtime error 3 ms 2588 KB Execution failed because the return code was nonzero
19 Runtime error 4 ms 2752 KB Execution failed because the return code was nonzero
20 Incorrect 3 ms 2568 KB Output isn't correct
21 Runtime error 12 ms 2848 KB Execution failed because the return code was nonzero
22 Runtime error 14 ms 2808 KB Execution failed because the return code was nonzero
23 Runtime error 13 ms 2852 KB Execution failed because the return code was nonzero
24 Runtime error 12 ms 2848 KB Execution failed because the return code was nonzero
25 Runtime error 12 ms 2852 KB Execution failed because the return code was nonzero
26 Runtime error 12 ms 2856 KB Execution failed because the return code was nonzero
27 Runtime error 12 ms 3108 KB Execution failed because the return code was nonzero
28 Runtime error 12 ms 2852 KB Execution failed because the return code was nonzero
29 Runtime error 13 ms 2852 KB Execution failed because the return code was nonzero
30 Incorrect 14 ms 2848 KB Output isn't correct
31 Runtime error 0 ms 2392 KB Execution failed because the return code was nonzero
32 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero