답안 #718634

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
718634 2023-04-04T12:51:34 Z vinnipuh01 Let's Win the Election (JOI22_ho_t3) C++17
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string>
#include <map>
#include <queue>
#define int double
#define sqrt sqrtl

using namespace std;

const long long oo = 1e9;

long double sum, ans = 0, mx = 0, mn = 1000000000, num, pos;


/*
    ViHHiPuh

   (( `'-""``""-'` ))
     )-__-_.._-__-(
   / --- (o _ o) --- \
   \ .-* ( .0. ) *-. /
   _'-. ,_ '=' _, .-'_
  / `;#'#'# - #'#'#;` \
 \_)) -----'#'----- ((_/
      # --------- #
  '# ------- ------ #'
  /..-'# ------- #'-.\
  _\...-\'# -- #'/-.../_
  ((____)- '#' -(____))


    cout << fixed << setprecision(6) << x;


    freopen ( "sum.in", "r", stdin )
*/

long long n, m;
int a[ 501 ], b[ 501 ];
int dp[ 501 ][ 501 ][ 501 ];

main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for ( long long i = 1; i <= n; i ++ ) {
		cin >> a[ i ] >> b[ i ];
		if ( b[ i ] == -1 )
			b[ i ] = oo;
	}
	ans = oo;
	for ( long long t = 0; t <= n; t ++ ) {
		for ( long long i = 0; i <= n; i ++ )
			for ( long long j = 0; j <= n; j ++ )
				dp[ t ][ i ][ j ] = oo;
		dp[ t ][ 0 ][ 0 ] = 0;
	}
	for ( long long k = 0; k <= m; k ++ ) {
		for ( long long i = 1; i <= n; i ++ ) {
			for ( long long j = 1; j <= min( i, m ); j ++ ) {
				dp[ i ][ j ][ 0 ] = min( dp[ i - 1 ][ j ][ 0 ], dp[ i - 1 ][ j - 1 ][ 0 ] + a[ i ] / ( k + 1 ) );
				for ( long long t = 1; t <= min( j, k ); t ++ ) {
					dp[ i ][ j ][ t ] = min( dp[ i - 1 ][ j ][ t ], min( dp[ i - 1 ][ j - 1 ][ t ] + a[ i ] / ( k + 1 ), dp[ i - 1 ][ j - 1 ][ t - 1 ] + b[ i ] / t ) );
//					cout << i << " " << j << " " << t << " - " << dp[ i ][ j ][ t ] << "\n";
				}
			}
		}
//		cout << k << " - " << dp[ n ][ m ][ k ] << "\n";
		ans = min( ans, dp[ n ][ m ][ k ] );
	}
	cout << fixed << setprecision( 4 ) << ans;
}

Compilation message

Main.cpp:49:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   49 | main () {
      | ^~~~
Main.cpp: In function 'int main()':
Main.cpp:76:37: error: no matching function for call to 'min(long double&, double&)'
   76 |   ans = min( ans, dp[ n ][ m ][ k ] );
      |                                     ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
Main.cpp:76:37: note:   deduced conflicting types for parameter 'const _Tp' ('long double' and 'double')
   76 |   ans = min( ans, dp[ n ][ m ][ k ] );
      |                                     ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
Main.cpp:76:37: note:   deduced conflicting types for parameter 'const _Tp' ('long double' and 'double')
   76 |   ans = min( ans, dp[ n ][ m ][ k ] );
      |                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
Main.cpp:76:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long double'
   76 |   ans = min( ans, dp[ n ][ m ][ k ] );
      |                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
Main.cpp:76:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long double'
   76 |   ans = min( ans, dp[ n ][ m ][ k ] );
      |                                     ^