답안 #61142

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
61142 2018-07-25T08:50:30 Z dukati8 Gap (APIO16_gap) C++14
30 / 100
96 ms 3536 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i=a; i<int(b); i++)

long long findGap(int T, int N)
{
	if (T==1) {
		vector<long long> vals;
		long long hi=1e18;
		long long lo=0;
		long long ans1,ans2;
		rep (i,0,(N+1)/2) {
			assert(lo<=hi);
			MinMax(lo,hi,&ans1,&ans2);
			vals.push_back(ans1);
			vals.push_back(ans2);
			lo=ans1+1;
			hi=ans2-1;
		}
		sort(vals.begin(),vals.end());
		long long maxdist=0;
		rep (i,0,vals.size()-1) {
			maxdist=max(maxdist,vals[i+1]-vals[i]);
			//cout << maxdist << endl;
		}
		return maxdist;
	}
	if (T==2) {
		long long NL=N;
		long long one=1;
		vector<long long> vals;
		long long hi,lo;
		MinMax(0,1e18,&lo,&hi);
		//Vi har nu max och min för alla tal.
		long long expdist=(hi-lo)/(NL-one);
		vals.push_back(hi);
		vals.push_back(lo);
		for (long long i=0; i<NL-one;i++) {
			long long start,stop;
			start=lo+one+(i*(hi-lo))/(NL-one);
			stop=start+(hi-lo)/(NL-one)-one;
			//stop=lo+((i+one)*(hi-lo))/(NL-one);
			assert(start<=stop);
			long long ans1,ans2;
			MinMax(start,stop,&ans1,&ans2);
			if (ans1!=-1) vals.push_back(ans1);
			if (ans2!=-1) vals.push_back(ans2);
		}
		sort(vals.begin(),vals.end());
		long long maxdist=0;
		rep (i,0,vals.size()-1) maxdist=max(maxdist,vals[i+1]-vals[i]);
		//assert(maxdist>=expdist);
		return maxdist;
	}

}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:36:13: warning: unused variable 'expdist' [-Wunused-variable]
   long long expdist=(hi-lo)/(NL-one);
             ^~~~~~~
gap.cpp:57:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 3 ms 484 KB Output is correct
3 Correct 3 ms 484 KB Output is correct
4 Correct 3 ms 484 KB Output is correct
5 Correct 3 ms 616 KB Output is correct
6 Correct 3 ms 616 KB Output is correct
7 Correct 3 ms 672 KB Output is correct
8 Correct 3 ms 672 KB Output is correct
9 Correct 3 ms 672 KB Output is correct
10 Correct 2 ms 672 KB Output is correct
11 Correct 3 ms 724 KB Output is correct
12 Correct 4 ms 724 KB Output is correct
13 Correct 4 ms 724 KB Output is correct
14 Correct 4 ms 724 KB Output is correct
15 Correct 4 ms 724 KB Output is correct
16 Correct 22 ms 1136 KB Output is correct
17 Correct 26 ms 1136 KB Output is correct
18 Correct 18 ms 1136 KB Output is correct
19 Correct 23 ms 1136 KB Output is correct
20 Correct 20 ms 1136 KB Output is correct
21 Correct 78 ms 2476 KB Output is correct
22 Correct 80 ms 2660 KB Output is correct
23 Correct 75 ms 2660 KB Output is correct
24 Correct 71 ms 2660 KB Output is correct
25 Correct 65 ms 2660 KB Output is correct
26 Correct 96 ms 2660 KB Output is correct
27 Correct 75 ms 2660 KB Output is correct
28 Correct 90 ms 2660 KB Output is correct
29 Correct 76 ms 2660 KB Output is correct
30 Correct 60 ms 2660 KB Output is correct
31 Correct 3 ms 2660 KB Output is correct
32 Correct 3 ms 2660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2660 KB Output is correct
2 Incorrect 2 ms 2660 KB Output isn't correct
3 Incorrect 3 ms 2660 KB Output isn't correct
4 Correct 3 ms 2660 KB Output is correct
5 Correct 3 ms 2660 KB Output is correct
6 Incorrect 3 ms 2660 KB Output isn't correct
7 Incorrect 3 ms 2660 KB Output isn't correct
8 Incorrect 3 ms 2660 KB Output isn't correct
9 Incorrect 3 ms 2660 KB Output isn't correct
10 Correct 2 ms 2660 KB Output is correct
11 Incorrect 4 ms 2660 KB Output isn't correct
12 Incorrect 5 ms 2660 KB Output isn't correct
13 Incorrect 4 ms 2660 KB Output isn't correct
14 Incorrect 4 ms 2660 KB Output isn't correct
15 Correct 4 ms 2660 KB Output is correct
16 Incorrect 17 ms 2660 KB Output isn't correct
17 Incorrect 18 ms 2660 KB Output isn't correct
18 Incorrect 17 ms 2660 KB Output isn't correct
19 Incorrect 18 ms 2660 KB Output isn't correct
20 Correct 17 ms 2660 KB Output is correct
21 Incorrect 67 ms 2660 KB Output isn't correct
22 Incorrect 83 ms 2660 KB Output isn't correct
23 Incorrect 90 ms 2660 KB Output isn't correct
24 Incorrect 66 ms 2660 KB Output isn't correct
25 Correct 87 ms 3536 KB Output is correct
26 Incorrect 69 ms 3536 KB Output isn't correct
27 Incorrect 67 ms 3536 KB Output isn't correct
28 Incorrect 61 ms 3536 KB Output isn't correct
29 Incorrect 60 ms 3536 KB Output isn't correct
30 Correct 47 ms 3536 KB Output is correct
31 Incorrect 3 ms 3536 KB Output isn't correct
32 Incorrect 3 ms 3536 KB Output isn't correct