Submission #694052

# Submission time Handle Problem Language Result Execution time Memory
694052 2023-02-03T16:17:12 Z Elephant52 Sure Bet (CEOI17_sure) C++11
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>

using namespace std;
  
int main() {
	ios::sync_with_stdio(false), cin.tie(nullptr);
	int N;
	cin >> N;
 
	vector<double> a(N), b(N);
	for(int i = 0; i < N; ++i)
		cin >> a[i] >> b[i];
 
	sort(a.begin(), a.end(), greater<>());
	sort(b.begin(), b.end(), greater<>());
 
	double ans = 0;
	int bets_taken = 0;
 
	int ap = 0, bp = 0;
	double a_sum = 0, b_sum = 0;
 
	for (int i = 0; i < 2 * N; ++i) {
		if (ap < N && bp < N) {
			if (a_sum < b_sum) {
				a_sum += a[ap++];
			} else {
				b_sum += b[bp++];
			}
		} else if (ap < N) {
			a_sum += a[ap++];
		} else if (bp < N) {
			b_sum += b[bp++];
		} else {
			assert(0);
		}
 
		++bets_taken;
		ans = max(ans, min(a_sum, b_sum) - bets_taken);
	}
	cout << fixed << setprecision(4) << ans << endl;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:14:35: error: wrong number of template arguments (0, should be 1)
   14 |  sort(a.begin(), a.end(), greater<>());
      |                                   ^
In file included from /usr/include/c++/10/string:48,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from sure.cpp:1:
/usr/include/c++/10/bits/stl_function.h:371:12: note: provided for 'template<class _Tp> struct std::greater'
  371 |     struct greater : public binary_function<_Tp, _Tp, bool>
      |            ^~~~~~~
sure.cpp:15:35: error: wrong number of template arguments (0, should be 1)
   15 |  sort(b.begin(), b.end(), greater<>());
      |                                   ^
In file included from /usr/include/c++/10/string:48,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from sure.cpp:1:
/usr/include/c++/10/bits/stl_function.h:371:12: note: provided for 'template<class _Tp> struct std::greater'
  371 |     struct greater : public binary_function<_Tp, _Tp, bool>
      |            ^~~~~~~