Submission #937940

# Submission time Handle Problem Language Result Execution time Memory
937940 2024-03-04T16:59:07 Z Litusiano Let's Win the Election (JOI22_ho_t3) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
const int INF = 1e18;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());

bool cmp(pair<int,int> a, pair<int,int> b){
	if(a.second == b.second) return a.first < b.first;
	return a.second-a.first < b.second-a.first;
}

void shuffle(vector<pair<int,int>>& v){
	int n = v.size();
	for(int i = 0; i<3*n; i++){
		int a = rng()%n; int b = rng()%n;
		swap(v[a],v[b]);
	}
 
}

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	setprecision(3)<<fixed
	int n,k1; cin>>n>>k1;
	vector<pair<int,int>> v(n);
	for(int i = 0; i<n; i++){
		cin>>v[i].first>>v[i].second;
		if(v[i].second == -1) v[i].second = INF;
	}
	sort(v.begin(),v.end(),cmp);
	long double ans = INF;
	// do{
		// shuffle(v);
		long double dp[n+1][k1+1][k1+1];
		for(int i = 0; i<=n; i++){
			for(int j = 0; j<=k1; j++){
				for(int k = 0; k<=k1; k++) dp[i][j][k] = 1.0*INF;
			}
		}
		dp[0][0][0] = 0; // first i, j votes, k representants
		for(int i = 1; i<=n; i++){
			for(int j = 0; j<=k1; j++){
				for(int k = 0; k<=k; k++){
					dp[i][j][k] = dp[i-1][j][k];
					if(!j) continue;
					long double act = dp[i-1][j-1][k]; // just speech for vote
					act+= 1.0*v[i-1].first/(k+1);
					dp[i][j][k] = min(dp[i][j][k],act);
					if(!k || v[i-1].second == INF) continue;
					act = dp[i-1][j-1][k-1];
					act+= 1.0*v[i-1].second / k;
					dp[i][j][k] = min(dp[i][j][k],act);
				}
			}
		}
		for(int k = 0; k<=k1; k++){
			ans = min(ans, dp[n][k1][k]);
		}
	// }while(next_permutation(v.begin(),v.end()));
	cout<<ans<<endl;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:25:17: error: no match for 'operator<<' (operand types are 'std::_Setprecision' and 'std::ios_base&(std::ios_base&)')
   25 |  setprecision(3)<<fixed
      |  ~~~~~~~~~~~~~~~^~~~~~~
      |              |    |
      |              |    std::ios_base&(std::ios_base&)
      |              std::_Setprecision
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from Main.cpp:1:
/usr/include/c++/10/bits/regex.h:1647:5: note: candidate: 'template<class _Ch_type, class _Ch_traits, class _Bi_iter> std::basic_ostream<_CharT, _Traits>& std::__cxx11::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::__cxx11::sub_match<_Bi_iter>&)'
 1647 |     operator<<(basic_ostream<_Ch_type, _Ch_traits>& __os,
      |     ^~~~~~~~
/usr/include/c++/10/bits/regex.h:1647:5: note:   template argument deduction/substitution failed:
Main.cpp:25:19: note:   'std::_Setprecision' is not derived from 'std::basic_ostream<_CharT, _Traits>'
   25 |  setprecision(3)<<fixed
      |                   ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:45,
                 from Main.cpp:1:
/usr/include/c++/10/cstddef:125:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator<<(std::byte, _IntegerType)'
  125 |     operator<<(byte __b, _IntegerType __shift) noexcept
      |     ^~~~~~~~
/usr/include/c++/10/cstddef:125:5: note:   template argument deduction/substitution failed:
Main.cpp:25:14: note:   cannot convert 'std::setprecision(3)' (type 'std::_Setprecision') to type 'std::byte'
   25 |  setprecision(3)<<fixed
      |  ~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/bits/basic_string.h:48,
                 from /usr/include/c++/10/string:55,
                 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 Main.cpp:1:
/usr/include/c++/10/string_view:622:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, std::basic_string_view<_CharT, _Traits>)'
  622 |     operator<<(basic_ostream<_CharT, _Traits>& __os,
      |     ^~~~~~~~
/usr/include/c++/10/string_view:622:5: note:   template argument deduction/substitution failed:
Main.cpp:25:19: note:   'std::_Setprecision' is not derived from 'std::basic_ostream<_CharT, _Traits>'
   25 |  setprecision(3)<<fixed
      |                   ^~~~~
In file included from /usr/include/c++/10/string:55,
                 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 Main.cpp:1:
/usr/include/c++/10/bits/basic_string.h:6458:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 6458 |     operator<<(basic_ostream<_CharT, _Traits>& __os,
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6458:5: note:   template argument deduction/substitution failed:
Main.cpp:25:19: note:   'std::_Setprecision' is not derived from 'std::basic_ostream<_CharT, _Traits>'
   25 |  setprecision(3)<<fixed
      |                   ^~~~~
In file included from /usr/include/c++/10/bits/ios_base.h:46,
                 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 Main.cpp:1:
/usr/include/c++/10/system_error:262:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::error_code&)'
  262 |     operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)
      |     ^~~~~~~~
/usr/include/c++/10/system_error:262:5: note:   template argument deduction/substitution failed:
Main.cpp:25:19: note:   'std::_Setprecision' is not derived from 'std::basic_ostream<_CharT, _Traits>'
   25 |  setprecision(3)<<fixed
      |                   ^~~~~
In file included from /usr/include/c++/10/istream:39,
                 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 Main.cpp:1:
/usr/include/c++/10/ostream:506:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, _CharT)'
  506 |     operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
      |     ^~~~~~~~
/usr/include/c++/10/ostream:506:5: note:   template argument deduction/substitution failed:
Main.cpp:25:19: note:   'std::_Setprecision' is not derived from 'std::basic_ostream<_CharT, _Traits>'
   25 |  setprecision(3)<<fixed
      |                   ^~~~~
In file included from /usr/include/c++/10/istream:39,
                 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 Main.cpp:1:
/usr/include/c++/10/ostream:511:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, char)'
  511 |     operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
      |     ^~~~~~~~
/usr/include/c++/10/ostream:511:5: note:   template argument deduction/substitution failed:
Main.cpp:25:19: note:   'std::_Setprecision' is not derived from 'std::basic_ostream<_CharT, _Traits>'
   25 |  setprecision(3)<<fixed
      |                   ^~~~~
In file included from /usr/include/c++/10/istream:39,
                 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 Main.cpp:1:
/usr/include/c++/10/ostream:517:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, char)'
  517 |     operator<<(basic_ostream<char, _Traits>& __out, char __c)
      |     ^~~~~~~~
/usr/include/c++/10/ostream:517:5: note:   template argument deduction/substitution failed:
Main.cpp:25:19: note:   'std::_Setprecision' is not derived from 'std::basic_ostream<char, _Traits>'
   25 |  setprecision(3)<<fixed
      |                   ^~~~~
In file included from /usr/include/c++/10/istream:39,
                 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 Main.cpp:1:
/usr/include/c++/10/ostream:523:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, signed char)'
  523 |     operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
      |     ^~~~~~~~
/usr/include/c++/10/ostream:523:5: note:   template argument deduction/substitution failed:
Main.cpp:25:19: note:   'std::_Setprecision' is not derived from 'std::basic_ostream<char, _Traits>'
   25 |  setprecision(3)<<fixed
      |                   ^~~~~
In file included from /usr/include/c++/10/istream:39,
                 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 Main.cpp:1:
/usr/include/c++/10/ostream:528:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, unsigned char)'
  528 |     operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
      |     ^~~~~~~~
/usr/include/c++/10/ostream:528:5: note:   template argument deduction/substitution failed:
Main.cpp:25:19: note:   'std::_Setprecision' is not derived from 'std::basic_ostream<char, _Traits>'
   25 |  setprecision(3)<<fixed
      |                   ^~~~~
In file included from /usr/include/c++/10/istream:39,
                 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 Main.cpp:1:
/usr/include/c++/10/ostream:589:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const _CharT*)'
  589 |     operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)
      |     ^~~~~~~~
/usr/include/c++/10/ostream:589:5: note:   template argument deduction/substitution failed:
Main.cpp:25:19: note:   'std::_Setprecision' is not derived from 'std::basic_ostream<_CharT, _Traits>'
   25 |  setprecision(3)<<fixed
      |                   ^~~~~
In file included from /usr/include/c++/10/ostream:784,
                 from /usr/include/c++/10/istream:39,
                 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 Main.cpp:1:
/usr/include/c++/10/bits/ostream.tcc:321:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const char*)'
  321 |     operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)
      |     ^~~~~~~~
/usr/include/c++/10/bits/ostream.tcc:321:5: note:   template argument deduction/substitution failed:
Main.cpp:25:19: note:   'std::_Setprecision' is not derived from 'std::basic_ostream<_CharT, _Traits>'
   25 |  setprecision(3)<<fixed
      |                   ^~~~~
In file included from /usr/include/c++/10/istream:39,
                 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 Main.cpp:1:
/usr/include/c++/10/ostream:606:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const char*)'
  606 |     operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
      |     ^~~~~~~~
/usr/include/c++/10/ostream:606:5: note:   template argument deduction/substitution failed:
Main.cpp:25:19: note:   'std::_Setprecision' is not derived from 'std::basic_ostream<char, _Traits>'
   25 |  setprecision(3)<<fixed
      |                   ^~~~~
In file included from /usr/include/c++/10/istream:39,
                 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 Main.cpp:1:
/usr/include/c++/10/ostream:619:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const signed char*)'
  619 |     operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)
      |     ^~~~~~~~
/usr/include/c++/10/ostream:619:5: note:   template argument deduction/substitution failed:
Main.cpp:25:19: note:   'std::_Setprecision' is not derived from 'std::basic_ostream<char, _Traits>'
   25 |  setprecision(3)<<fixed
      |                   ^~~~~
In file included from /usr/include/c++/10/istream:39,
                 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 Main.cpp:1:
/usr/include/c++/10/ostream:624:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const unsigned char*)'
  624 |     operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)
      |     ^~~~~~~~
/usr/include/c++/10/ostream:624:5: note:   template argument deduction/substitution failed:
Main.cpp:25:19: note:   'std::_Setprecision' is not derived from 'std::basic_ostream<char, _Traits>'
   25 |  setprecision(3)<<fixed
      |                   ^~~~~
In file included from /usr/include/c++/10/istream:39,
                 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 Main.cpp:1:
/usr/include/c++/10/ostream:773:5: note: candidate: 'template<class _Ostream, class _Tp> typename std::enable_if<std::__and_<std::__not_<std::is_lvalue_reference<_Tp> >, std::__is_convertible_to_basic_ostream<_Ostream>, std::__is_insertable<typename std::__is_convertible_to_basic_ostream<_Tp>::__ostream_type, const _Tp&, void> >::value, typename std::__is_convertible_to_basic_ostream<_Tp>::__ostream_type>::type std::operator<<(_Ostream&&, const _Tp&)'
  773 |     operator<<(_Ostream&& __os, const _Tp& __x)
      |     ^~~~~~~~
/usr/include/c++/10/ostream:773:5: note:   template argument deduction/substitution failed:
/usr/include/c++/10/ostream: In substitution of 'template<class _Ostream, class _Tp> typename std::enable_if<std::__and_<std::__not_<std::is_lvalue_reference<_Tp> >, std::__is_convertible_to_basic_ostream<_Ostream>, std::__is_insertable<typename std::__is_convertible_to_basic_ostream<_Tp>::__ostream_type, const _Tp&, void> >::value, typename std::__is_convertible_to_basic_ostream<_Tp>::__ostream_type>::type std::operator<<(_Ostream&&, const _Tp&) [with _Ostream = std::_Setprecision; _Tp = std::ios_base&(std::ios_base&)]':
Main.cpp:25:19:   required from here
/usr/include/c++/10/ostream:773:5: error: no type named 'type' in 'struct std::enable_if<false, void>'
In file included from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from Main.cpp:1:
/usr/include/c++/10/complex:554:5: note: candidate: 'template<class _Tp, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::complex<_Tp>&)'
  554 |     operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)
      |     ^~~~~~~~
/usr/include/c++/10/complex:554:5: note:   template argument deduction/substitution failed:
Main.cpp:25:19: note:   'std::_Setprecision' is not derived from 'std::basic_ostream<_CharT, _Traits>'
   25 |  setprecision(3)<<fixed
      |                   ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:66,
                 from Main.cpp:1:
/usr/include/c++/10/bitset:1540:5: note: candidate: 'template<class _CharT, class _Traits, long unsigned int _Nb> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::bitset<_Nb>&)'
 1540 |     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
      |     ^~~~~~~~
/usr/include/c++/10/bitset:1540:5: note:   template argument deduction/substitution failed:
Main.cpp:25:19: note:   'std::_Setprecision' is not derived from 'std::basic_ostream<_CharT, _Traits>'
   25 |  setprecision(3)<<fixed
      |                   ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:72,
                 from Main.cpp:1:
/usr/include/c++/10/iomanip:79:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, std::_Resetiosflags)'
   79 |     operator<<(basic_ostream<_CharT, _Traits>& __os, _Resetiosflags __f)
      |     ^~~~~~~~
/usr/include/c++/10/iomanip:79:5: note:   template argument deduction/substitution failed:
Main.cpp:25:19: note:   'std::_Setprecision' is not derived from 'std::basic_ostream<_CharT, _Traits>'
   25 |  setprecision(3)<<fixed
      |                   ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:72,
                 from Main.cpp:1:
/usr/include/c++/10/iomanip:109:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, std::_Setiosflags)'
  109 |     operator<<(basic_ostream<_CharT, _Traits>& __os, _Setiosflags __f)
      |     ^~~~~~~~
/usr/include/c++/10/iomanip:109:5: note:   template argument deduction/substitution failed:
Main.cpp:25:19: note:   'std::_Setprecision' is not derived from 'std::basic_ostream<_CharT, _Traits>'
   25 |  setprecision(3)<<fixed
      |                   ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:72,
                 from Main.cpp:1:
/usr/include/c++/10/iomanip:143:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Tr