Submission #40767

# Submission time Handle Problem Language Result Execution time Memory
40767 2018-02-08T05:56:35 Z Just_Solve_The_Problem Gap (APIO16_gap) C++11
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include <gap.h>
                               
long long findGap(int t, int n) {
		long long left;
		long long right;
		left = 1;
		right = 1e18;
		long long mn, mx;        
		long long vec[n];
		int cnt = 0;
		int cnn = n - 1;
		while (mn != mx) {
			MinMax(left, right, &mn, &mx);
			vec[cnt++] = mn; 
			if (mn != mx)
				vec[cn--] = mx;
			left = mn + 1;
			right= mx - 1;	
		}                  
		long long ans = 0;
		for (int i = 1; i < n; i++) {
			ans = max(ans, vec[i] - vec[i - 1]);
		}
		return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:17:9: error: 'cn' was not declared in this scope
     vec[cn--] = mx;
         ^
gap.cpp:23:38: error: 'max' was not declared in this scope
    ans = max(ans, vec[i] - vec[i - 1]);
                                      ^
gap.cpp:23:38: note: suggested alternative:
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from gap.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3463:5: note:   'std::max'
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^
gap.cpp:12:7: warning: unused variable 'cnn' [-Wunused-variable]
   int cnn = n - 1;
       ^