답안 #262887

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
262887 2020-08-13T10:34:20 Z sahil_k Semiexpress (JOI17_semiexpress) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long n, m, k;
long long a, b, c;
long long t;
long long pos[3005];
long long o = 0;
vector<long long> opts;
int main () {
	cin >> n >> m >> k;
	cin >> a >> b >> c;
	cin >> t;
	for (int i=0; i<m; i++) {
		cin >> pos[i];
		pos[i]--;
	}
	for (int i=0; i<m-1; i++) {
		long long dist = pos[i]*b;
		if (dist > t) break;
		long long temp = min(pos[i+1]-pos[i], (t-dist)/a+1);
		o += max(0ll, temp);
		long long nxt = pos[i]+temp;
		dist += temp*c;
		for (int j=1; j<=k; j++) {
			if (nxt >= pos[i+1] || dist > t) break;
			long long temp = min(pos[i+1]-nxt, (t-dist)/a+1);
			opts.push_back(temp);
			nxt += temp;
			dist += temp*c;
		}
	}
	if ((n-1)*b <= t) o++;
	sort(opts.begin(), opts.end(), greater<long long>());
	for (int i=0; i<max(opts.size(), k-m); i++) {
		o += opts[i];
	}
	cout << o-1 << endl;
}

Compilation message

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:36:38: error: no matching function for call to 'max(std::vector<long long int>::size_type, long long int)'
   36 |  for (int i=0; i<max(opts.size(), k-m); i++) {
      |                                      ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from semiexpress.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
semiexpress.cpp:36:38: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'long long int')
   36 |  for (int i=0; i<max(opts.size(), k-m); i++) {
      |                                      ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from semiexpress.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
semiexpress.cpp:36:38: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'long long int')
   36 |  for (int i=0; i<max(opts.size(), k-m); i++) {
      |                                      ^
In file included from /usr/include/c++/9/algorithm:62,
                 from semiexpress.cpp:3:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
semiexpress.cpp:36:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   36 |  for (int i=0; i<max(opts.size(), k-m); i++) {
      |                                      ^
In file included from /usr/include/c++/9/algorithm:62,
                 from semiexpress.cpp:3:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
semiexpress.cpp:36:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   36 |  for (int i=0; i<max(opts.size(), k-m); i++) {
      |                                      ^