Submission #47282

# Submission time Handle Problem Language Result Execution time Memory
47282 2018-04-30T06:10:27 Z yogahmad Gap (APIO16_gap) C++14
70 / 100
105 ms 3552 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){
			if(*kiri>*kanan)
				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]);
		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:27:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=1;i<ve.size();i++)
               ~^~~~~~~~~~
gap.cpp:60: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 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
3 Runtime error 2 ms 432 KB Execution failed because the return code was nonzero
4 Runtime error 2 ms 432 KB Execution failed because the return code was nonzero
5 Runtime error 2 ms 488 KB Execution failed because the return code was nonzero
6 Incorrect 2 ms 564 KB Output isn't correct
7 Incorrect 2 ms 564 KB Output isn't correct
8 Incorrect 2 ms 620 KB Output isn't correct
9 Incorrect 2 ms 728 KB Output isn't correct
10 Runtime error 2 ms 748 KB Execution failed because the return code was nonzero
11 Incorrect 3 ms 748 KB Output isn't correct
12 Incorrect 3 ms 748 KB Output isn't correct
13 Incorrect 3 ms 748 KB Output isn't correct
14 Incorrect 3 ms 748 KB Output isn't correct
15 Incorrect 3 ms 748 KB Output isn't correct
16 Incorrect 18 ms 1148 KB Output isn't correct
17 Incorrect 16 ms 1148 KB Output isn't correct
18 Incorrect 17 ms 1148 KB Output isn't correct
19 Incorrect 18 ms 1148 KB Output isn't correct
20 Runtime error 11 ms 1148 KB Execution failed because the return code was nonzero
21 Incorrect 63 ms 2544 KB Output isn't correct
22 Incorrect 61 ms 2548 KB Output isn't correct
23 Incorrect 63 ms 2548 KB Output isn't correct
24 Incorrect 67 ms 2552 KB Output isn't correct
25 Incorrect 52 ms 2552 KB Output isn't correct
26 Incorrect 67 ms 2552 KB Output isn't correct
27 Incorrect 65 ms 2552 KB Output isn't correct
28 Incorrect 61 ms 2552 KB Output isn't correct
29 Incorrect 89 ms 2552 KB Output isn't correct
30 Runtime error 43 ms 2552 KB Execution failed because the return code was nonzero
31 Runtime error 2 ms 2552 KB Execution failed because the return code was nonzero
32 Runtime error 2 ms 2552 KB Execution failed because the return code was nonzero
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2552 KB Output is correct
2 Correct 2 ms 2552 KB Output is correct
3 Correct 2 ms 2552 KB Output is correct
4 Correct 2 ms 2552 KB Output is correct
5 Correct 2 ms 2552 KB Output is correct
6 Correct 2 ms 2552 KB Output is correct
7 Correct 2 ms 2552 KB Output is correct
8 Correct 2 ms 2552 KB Output is correct
9 Correct 2 ms 2552 KB Output is correct
10 Correct 2 ms 2552 KB Output is correct
11 Correct 3 ms 2552 KB Output is correct
12 Correct 3 ms 2552 KB Output is correct
13 Correct 3 ms 2552 KB Output is correct
14 Correct 3 ms 2552 KB Output is correct
15 Correct 3 ms 2552 KB Output is correct
16 Correct 20 ms 2552 KB Output is correct
17 Correct 20 ms 2552 KB Output is correct
18 Correct 20 ms 2552 KB Output is correct
19 Correct 20 ms 2552 KB Output is correct
20 Correct 10 ms 2552 KB Output is correct
21 Correct 91 ms 2552 KB Output is correct
22 Correct 105 ms 2552 KB Output is correct
23 Correct 77 ms 2660 KB Output is correct
24 Correct 78 ms 2660 KB Output is correct
25 Correct 76 ms 3552 KB Output is correct
26 Correct 79 ms 3552 KB Output is correct
27 Correct 79 ms 3552 KB Output is correct
28 Correct 82 ms 3552 KB Output is correct
29 Correct 80 ms 3552 KB Output is correct
30 Correct 38 ms 3552 KB Output is correct
31 Correct 2 ms 3552 KB Output is correct
32 Correct 2 ms 3552 KB Output is correct