답안 #1015161

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1015161 2024-07-06T06:52:45 Z vjudge1 Gap (APIO16_gap) C++17
70 / 100
32 ms 1240 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(mn+1<mx){
		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;
      |            ^~~
gap.cpp: In function 'long long int solve(int)':
gap.cpp:10:10: warning: 'mn' is used uninitialized in this function [-Wuninitialized]
   10 |  while(mn+1<mx){
      |        ~~^~
gap.cpp:10:12: warning: 'mx' is used uninitialized in this function [-Wuninitialized]
   10 |  while(mn+1<mx){
      |        ~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Incorrect 0 ms 344 KB Output isn't correct
4 Incorrect 0 ms 344 KB Output isn't correct
5 Incorrect 0 ms 344 KB Output isn't 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 416 KB Output is correct
10 Incorrect 0 ms 344 KB Output isn't 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 0 ms 344 KB Output is correct
15 Incorrect 1 ms 344 KB Output isn't correct
16 Correct 4 ms 600 KB Output is correct
17 Correct 4 ms 600 KB Output is correct
18 Correct 5 ms 600 KB Output is correct
19 Correct 5 ms 600 KB Output is correct
20 Incorrect 3 ms 468 KB Output isn't correct
21 Correct 17 ms 1108 KB Output is correct
22 Correct 19 ms 1112 KB Output is correct
23 Correct 16 ms 1112 KB Output is correct
24 Correct 18 ms 1040 KB Output is correct
25 Incorrect 32 ms 1112 KB Output isn't correct
26 Correct 17 ms 1112 KB Output is correct
27 Correct 25 ms 1112 KB Output is correct
28 Correct 17 ms 1112 KB Output is correct
29 Correct 17 ms 1112 KB Output is correct
30 Incorrect 14 ms 1112 KB Output isn't correct
31 Correct 0 ms 344 KB Output is correct
32 Incorrect 0 ms 344 KB Output isn't 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 372 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 1 ms 344 KB Output is correct
16 Correct 4 ms 600 KB Output is correct
17 Correct 7 ms 632 KB Output is correct
18 Correct 7 ms 600 KB Output is correct
19 Correct 5 ms 600 KB Output is correct
20 Correct 3 ms 600 KB Output is correct
21 Correct 17 ms 1200 KB Output is correct
22 Correct 17 ms 1112 KB Output is correct
23 Correct 16 ms 1112 KB Output is correct
24 Correct 19 ms 1112 KB Output is correct
25 Correct 32 ms 1240 KB Output is correct
26 Correct 17 ms 1112 KB Output is correct
27 Correct 17 ms 1112 KB Output is correct
28 Correct 18 ms 1112 KB Output is correct
29 Correct 17 ms 1112 KB Output is correct
30 Correct 13 ms 1112 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct