답안 #199986

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
199986 2020-02-04T16:15:20 Z mohammedehab2002 Gap (APIO16_gap) C++11
64.6316 / 100
66 ms 1912 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
long long solve(int n)
{
	long long f,l,ans=0;
	MinMax(0,1e18,&f,&l);
	deque<long long> d1({f}),d2({l});
	while (d1.size()+d2.size()<n)
	{
		MinMax(f+1,l-1,&f,&l);
		d1.push_back(f);
		d2.push_front(l);
	}
	for (int i=1;i<d1.size();i++)
	ans=max(ans,d1[i]-d1[i-1]);
	for (int i=1;i<d2.size();i++)
	ans=max(ans,d2[i]-d2[i-1]);
	return max(ans,d2.front()-d1.back());
}
long long findGap(int t,int n)
{
	if (t==1 || n<=10)
	return solve(n);
	long long f,l;
	MinMax(0,1e18,&f,&l);
	long long p=f+1,g=1;
	while (p<=l)
	{
		long long mn,mx;
		MinMax(p,p+g-1,&mn,&mx);
		if (mn==-1)
		{
			while (mn==-1)
			{
				g*=2;
				MinMax(p,p+g,&mn,&mx);
			}
			g=mn-p+1;
		}
		p=mx+1;
	}
	return g;
}

Compilation message

gap.cpp: In function 'long long int solve(int)':
gap.cpp:9:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while (d1.size()+d2.size()<n)
         ~~~~~~~~~~~~~~~~~~~^~
gap.cpp:15:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=1;i<d1.size();i++)
               ~^~~~~~~~~~
gap.cpp:17:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=1;i<d2.size();i++)
               ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 248 KB Output is correct
3 Correct 5 ms 248 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 248 KB Output is correct
6 Correct 5 ms 248 KB Output is correct
7 Correct 7 ms 248 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 252 KB Output is correct
10 Correct 5 ms 252 KB Output is correct
11 Correct 5 ms 248 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 248 KB Output is correct
14 Correct 5 ms 248 KB Output is correct
15 Correct 5 ms 248 KB Output is correct
16 Correct 21 ms 632 KB Output is correct
17 Correct 17 ms 712 KB Output is correct
18 Correct 17 ms 760 KB Output is correct
19 Correct 17 ms 760 KB Output is correct
20 Correct 15 ms 760 KB Output is correct
21 Correct 56 ms 1912 KB Output is correct
22 Correct 57 ms 1912 KB Output is correct
23 Correct 59 ms 1836 KB Output is correct
24 Correct 56 ms 1856 KB Output is correct
25 Correct 49 ms 1912 KB Output is correct
26 Correct 58 ms 1836 KB Output is correct
27 Correct 56 ms 1860 KB Output is correct
28 Correct 58 ms 1912 KB Output is correct
29 Correct 59 ms 1912 KB Output is correct
30 Correct 46 ms 1900 KB Output is correct
31 Correct 5 ms 296 KB Output is correct
32 Correct 5 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Partially correct 5 ms 376 KB Partially correct
3 Partially correct 5 ms 248 KB Partially correct
4 Partially correct 5 ms 292 KB Partially correct
5 Partially correct 4 ms 248 KB Partially correct
6 Correct 5 ms 248 KB Output is correct
7 Correct 5 ms 248 KB Output is correct
8 Correct 5 ms 248 KB Output is correct
9 Correct 5 ms 248 KB Output is correct
10 Correct 5 ms 248 KB Output is correct
11 Correct 5 ms 248 KB Output is correct
12 Correct 5 ms 248 KB Output is correct
13 Correct 5 ms 248 KB Output is correct
14 Correct 5 ms 248 KB Output is correct
15 Partially correct 5 ms 248 KB Partially correct
16 Correct 15 ms 508 KB Output is correct
17 Correct 14 ms 504 KB Output is correct
18 Correct 14 ms 584 KB Output is correct
19 Correct 14 ms 504 KB Output is correct
20 Correct 11 ms 504 KB Output is correct
21 Correct 41 ms 1016 KB Output is correct
22 Correct 43 ms 1144 KB Output is correct
23 Correct 44 ms 1352 KB Output is correct
24 Correct 41 ms 1008 KB Output is correct
25 Partially correct 66 ms 1116 KB Partially correct
26 Correct 41 ms 1016 KB Output is correct
27 Correct 43 ms 1000 KB Output is correct
28 Correct 43 ms 1192 KB Output is correct
29 Correct 43 ms 1148 KB Output is correct
30 Correct 38 ms 1144 KB Output is correct
31 Partially correct 5 ms 248 KB Partially correct
32 Correct 5 ms 376 KB Output is correct