Submission #742030

#TimeUsernameProblemLanguageResultExecution timeMemory
742030vjudge1Gap (APIO16_gap)C++17
Compilation error
0 ms0 KiB
long long findGap(int T, int N){
	if(T == 1){
		long long l = 0, r = 1e18, L = 1, R = N;
		long long a[N+1], mn, mx;
		int cnt = 0;
		while(L <= R){
			cnt++;
			MinMax(l, r, &mn, &mx);
			a[L] = mn, a[R] = mx;
			L++, R--;
			l = mn+1;
			r = mx-1;
		}
		if(cnt > (N+1)/2){
			for(int i=1; i<=1e9; i++) cout << "WA";
		}
		long long ans = 0;
		for(int i=2; i<=N; i++){
			ans = max(ans, a[i] - a[i-1]);
		}
		return ans;
	}
	long long l = 0, r = 1e18;
	vector<long long>a;
	long long mn, mx;
	long long L[N+1], R[N+1];
	MinMax(l, r, &mn, &mx);
	long long len = mx-mn+1;
	R[0] = mn-1;
	for(int i=1; i<N; i++){
		L[i] = R[i-1] + 1;
		R[i] = L[i] + len/(N-1);
		if(i > len%(N-1)) R[i]--;
		MinMax(L[i], R[i], &mn, &mx);
		a.push_back(mn);
		a.push_back(mx);
	}
	long long ans = (len+N-2) / (N-1);
	sort(a.begin(), a.end());
	for(int i=1; i<a.size(); i++) ans = max(ans, a[i]-a[i-1]);
	return ans;
}

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:8:4: error: 'MinMax' was not declared in this scope
    8 |    MinMax(l, r, &mn, &mx);
      |    ^~~~~~
gap.cpp:15:30: error: 'cout' was not declared in this scope
   15 |    for(int i=1; i<=1e9; i++) cout << "WA";
      |                              ^~~~
gap.cpp:19:10: error: 'max' was not declared in this scope; did you mean 'mx'?
   19 |    ans = max(ans, a[i] - a[i-1]);
      |          ^~~
      |          mx
gap.cpp:24:2: error: 'vector' was not declared in this scope
   24 |  vector<long long>a;
      |  ^~~~~~
gap.cpp:24:9: error: expected primary-expression before 'long'
   24 |  vector<long long>a;
      |         ^~~~
gap.cpp:27:2: error: 'MinMax' was not declared in this scope
   27 |  MinMax(l, r, &mn, &mx);
      |  ^~~~~~
gap.cpp:35:3: error: 'a' was not declared in this scope
   35 |   a.push_back(mn);
      |   ^
gap.cpp:39:7: error: 'a' was not declared in this scope
   39 |  sort(a.begin(), a.end());
      |       ^
gap.cpp:39:2: error: 'sort' was not declared in this scope; did you mean 'short'?
   39 |  sort(a.begin(), a.end());
      |  ^~~~
      |  short
gap.cpp:40:38: error: 'max' was not declared in this scope; did you mean 'mx'?
   40 |  for(int i=1; i<a.size(); i++) ans = max(ans, a[i]-a[i-1]);
      |                                      ^~~
      |                                      mx