Submission #40765

# Submission time Handle Problem Language Result Execution time Memory
40765 2018-02-08T05:50:58 Z ssnsarang2023 Gap (APIO16_gap) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "gap.h"

typedef long long ll;

ll findGap(int _t, int _n) {
	ll n = _n;
	ll mn = 1, mx = (ll)1e18;
	MinMax(mn, mx, &mn, &mx);
	ll d = (mx - mn) / n, mod = (mx - mn) % n, pre = mn;
	ll pstep = mn, step = mn + d + - 1 + mod, gap = 0;
	while (1) {
		ll mntmp = -1, mxtmp = -1;
		if (pstep <= min(mx - 1, step)) MinMax(pstep + 1, min(mx - 1, step), &mntmp, &mxtmp);
		if (step >= mx) {
			if (mxtmp != -1) gap = max(gap, mx - mxtmp);
			else gap = max(gap, mx - pre);
		} else if (mntmp != -1) gap = max(gap, mntmp - pre);
		pre = mxtmp, pstep = step, step += d;
	}
	return gap;
}

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:14:32: error: 'min' was not declared in this scope
   if (pstep <= min(mx - 1, step)) MinMax(pstep + 1, min(mx - 1, step), &mntmp, &mxtmp);
                                ^
gap.cpp:14:32: 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:3451:5: note:   'std::min'
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^
gap.cpp:16:46: error: 'max' was not declared in this scope
    if (mxtmp != -1) gap = max(gap, mx - mxtmp);
                                              ^
gap.cpp:16:46: 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:17:32: error: 'max' was not declared in this scope
    else gap = max(gap, mx - pre);
                                ^
gap.cpp:17:32: 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:18:53: error: 'max' was not declared in this scope
   } else if (mntmp != -1) gap = max(gap, mntmp - pre);
                                                     ^
gap.cpp:18:53: 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)
     ^