답안 #1015165

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1015165 2024-07-06T06:56:28 Z vjudge1 Gap (APIO16_gap) C++17
100 / 100
32 ms 2764 KB
#include "gap.h"
#include <bits/stdc++.h>
// #include "grader.cpp"
using namespace std;
long long solve(int n){
	long long mn,mx;
	long long s=0,t=1e18;
	vector<long long> arr;
	vector<long long> a1;
	while(int(arr.size())+int(a1.size())<n){
		MinMax(s,t,&mn,&mx);
		if(mn==-1)
			break;
		s=mn+1;
		t=mx-1;
		arr.push_back(mn);
		a1.push_back(mx);
	}
	reverse(a1.begin(), a1.end());
	for(long long i:a1)
		arr.push_back(i);
	long long g=0;
	for(int i=1;i<arr.size();i++)
		g=max(g,arr[i]-arr[i-1]);
	return g;
}
long long findGap(int T, int N)
{
	if(T==1)
		return solve(N);
	long long mn,mx;
	long long s=0,t=1e18;
	MinMax(s,t,&mn,&mx);
	s=mn+1,t=mx;
	long long gap=(t-s)/(N-1);
	long long ans=0;
	long long pre=mn;
	while(s<t){
		MinMax(s,min(s+gap,t),&mn,&mx);
		if(mn==-1)
			s+=gap;
		else{
			gap=max(gap,mn-pre);
			s=mx+1;
			pre=mx;
		}
	}
	return gap;
}

Compilation message

gap.cpp: In function 'long long int solve(int)':
gap.cpp:23:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for(int i=1;i<arr.size();i++)
      |              ~^~~~~~~~~~~
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:36:12: warning: unused variable 'ans' [-Wunused-variable]
   36 |  long long ans=0;
      |            ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 6 ms 972 KB Output is correct
17 Correct 6 ms 1112 KB Output is correct
18 Correct 7 ms 968 KB Output is correct
19 Correct 7 ms 1112 KB Output is correct
20 Correct 5 ms 1112 KB Output is correct
21 Correct 27 ms 2640 KB Output is correct
22 Correct 25 ms 2676 KB Output is correct
23 Correct 26 ms 2684 KB Output is correct
24 Correct 26 ms 2676 KB Output is correct
25 Correct 26 ms 2684 KB Output is correct
26 Correct 25 ms 2764 KB Output is correct
27 Correct 27 ms 2684 KB Output is correct
28 Correct 28 ms 2684 KB Output is correct
29 Correct 27 ms 2684 KB Output is correct
30 Correct 23 ms 2684 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 5 ms 648 KB Output is correct
17 Correct 7 ms 612 KB Output is correct
18 Correct 4 ms 460 KB Output is correct
19 Correct 5 ms 600 KB Output is correct
20 Correct 5 ms 600 KB Output is correct
21 Correct 16 ms 1144 KB Output is correct
22 Correct 17 ms 1112 KB Output is correct
23 Correct 24 ms 1112 KB Output is correct
24 Correct 16 ms 1112 KB Output is correct
25 Correct 32 ms 1112 KB Output is correct
26 Correct 18 ms 1112 KB Output is correct
27 Correct 16 ms 1112 KB Output is correct
28 Correct 18 ms 1112 KB Output is correct
29 Correct 23 ms 1012 KB Output is correct
30 Correct 14 ms 1112 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct