Submission #47283

# Submission time Handle Problem Language Result Execution time Memory
47283 2018-04-30T06:14:07 Z yogahmad Gap (APIO16_gap) C++14
70 / 100
87 ms 3544 KB
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
long long findGap(int T, int N)
{
	if(T==1){
		long long sa,du;
		long long *kiri,*kanan;
		kiri=&sa;
		kanan=&du;
		MinMax(0,1e18,kiri,kanan);
		vector<long long>ve;
		ve.push_back(*kiri);
		long long jaw=0;
		ve.push_back(*kanan);
		while(1){
		//	cout<<*kiri<<" "<<*kanan<<endl;
			if(*kiri>*kanan)
				break;
			if(*kiri+1>*kanan-1)
				break;
			MinMax(*kiri+1,*kanan-1,kiri,kanan);
			if(*kiri==-1 && *kanan==-1)
				break;
			ve.push_back(*kiri);
			ve.push_back(*kanan);
		}
		sort(ve.begin(),ve.end());
		for(int i=1;i<ve.size();i++)
			jaw=max(jaw,ve[i]-ve[i-1]);
	//	cout<<jaw<<endl;
		return jaw;
	}
//	cout<<T<<" "<<N<<endl;
	long long sa,du,ti,em;
	vector<long long>ve;
	long long *kiri,*kanan;
	kiri=&sa;
	kanan=&du;
	MinMax(0,1e18,kiri,kanan);
//	cout<<*kiri<<' '<<*kanan<<endl;
	long long gap=(*kanan-*kiri)/(N-1);
	long long jaw=0;
//	cout<<*kiri<<" "<<*kanan<<" "<<gap<<endl;
	long long awal;
	for(awal=*kiri;awal<=*kanan;awal+=gap+1){
	//	cout<<awal<<" <<<___\n";
		long long *lo,*hi;
		lo=&ti;
		hi=&em;
		MinMax(awal,awal+gap,lo,hi);
	//	cout<<awal<<' '<<awal+gap<<" -> "<<*lo<<" "<<*hi<<endl;
		if(*lo==-1 && *hi==-1)
			continue;
		ve.push_back(*lo);
		ve.push_back(*hi);
	}
//	cout<<awal<<endl;
	sort(ve.begin(),ve.end());
//	for(int i:ve)
	//	cout<<i<<' ';
//	cout<<endl;
	for(int i=1;i<ve.size();i++){
		jaw=max(jaw,ve[i]-ve[i-1]);
	}
//	cout<<jaw<<endl;
	return jaw;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:29:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=1;i<ve.size();i++)
               ~^~~~~~~~~~
gap.cpp:63:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=1;i<ve.size();i++){
              ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 2 ms 640 KB Output is correct
6 Incorrect 2 ms 640 KB Output isn't correct
7 Incorrect 2 ms 820 KB Output isn't correct
8 Incorrect 2 ms 820 KB Output isn't correct
9 Incorrect 2 ms 820 KB Output isn't correct
10 Correct 2 ms 820 KB Output is correct
11 Incorrect 3 ms 820 KB Output isn't correct
12 Incorrect 3 ms 820 KB Output isn't correct
13 Incorrect 3 ms 820 KB Output isn't correct
14 Incorrect 3 ms 820 KB Output isn't correct
15 Incorrect 2 ms 820 KB Output isn't correct
16 Incorrect 17 ms 1116 KB Output isn't correct
17 Incorrect 16 ms 1116 KB Output isn't correct
18 Incorrect 17 ms 1116 KB Output isn't correct
19 Incorrect 17 ms 1116 KB Output isn't correct
20 Correct 13 ms 1116 KB Output is correct
21 Incorrect 63 ms 2512 KB Output isn't correct
22 Incorrect 79 ms 2544 KB Output isn't correct
23 Incorrect 75 ms 2544 KB Output isn't correct
24 Incorrect 69 ms 2548 KB Output isn't correct
25 Incorrect 54 ms 2548 KB Output isn't correct
26 Incorrect 62 ms 2548 KB Output isn't correct
27 Incorrect 63 ms 2568 KB Output isn't correct
28 Incorrect 63 ms 2568 KB Output isn't correct
29 Incorrect 61 ms 2568 KB Output isn't correct
30 Correct 59 ms 2676 KB Output is correct
31 Correct 2 ms 2676 KB Output is correct
32 Correct 2 ms 2676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2676 KB Output is correct
2 Correct 2 ms 2676 KB Output is correct
3 Correct 2 ms 2676 KB Output is correct
4 Correct 2 ms 2676 KB Output is correct
5 Correct 2 ms 2676 KB Output is correct
6 Correct 2 ms 2676 KB Output is correct
7 Correct 2 ms 2676 KB Output is correct
8 Correct 2 ms 2676 KB Output is correct
9 Correct 2 ms 2676 KB Output is correct
10 Correct 2 ms 2676 KB Output is correct
11 Correct 3 ms 2676 KB Output is correct
12 Correct 3 ms 2676 KB Output is correct
13 Correct 3 ms 2676 KB Output is correct
14 Correct 3 ms 2676 KB Output is correct
15 Correct 3 ms 2676 KB Output is correct
16 Correct 21 ms 2676 KB Output is correct
17 Correct 20 ms 2676 KB Output is correct
18 Correct 20 ms 2676 KB Output is correct
19 Correct 20 ms 2676 KB Output is correct
20 Correct 11 ms 2676 KB Output is correct
21 Correct 80 ms 2676 KB Output is correct
22 Correct 78 ms 2676 KB Output is correct
23 Correct 78 ms 2676 KB Output is correct
24 Correct 81 ms 2676 KB Output is correct
25 Correct 75 ms 3544 KB Output is correct
26 Correct 79 ms 3544 KB Output is correct
27 Correct 80 ms 3544 KB Output is correct
28 Correct 78 ms 3544 KB Output is correct
29 Correct 87 ms 3544 KB Output is correct
30 Correct 38 ms 3544 KB Output is correct
31 Correct 2 ms 3544 KB Output is correct
32 Correct 2 ms 3544 KB Output is correct