Submission #865458

#TimeUsernameProblemLanguageResultExecution timeMemory
865458NotLinuxLet's Win the Election (JOI22_ho_t3)C++17
0 / 100
9 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define int long long void solve(){ int n,k;cin >> n >> k; int a[n],b[n]; vector < pair < int , int > > v; for(int i = 0;i<n;i++){ cin >> a[i] >> b[i]; if(b[i] != -1){ v.push_back({b[i],i}); } } sort(v.begin() , v.end()); long double ans = 1e18 + 7; for(int t = 0;t<=v.size();t++){ vector < int > tempa(n); for(int i = 0;i<n;i++)tempa[i] = a[i]; long double curans = 0; for(int i = t-1;i>=0;i--){ curans += (long double)v[i].first / (long double)(t - i); tempa[v[i].second] = 0; } cout << curans << endl; sort(tempa.begin() , tempa.end()); for(int i = 0;i<k;i++){ curans += (long double)tempa[i] / (long double)(t+1); } cout << curans << endl; ans = min(ans , curans); } cout << fixed << setprecision(6) << ans << endl; } signed main(){ ios_base::sync_with_stdio(0);cin.tie(0); int testcase = 1;//cin >> testcase; while(testcase--)solve(); }

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:16:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  for(int t = 0;t<=v.size();t++){
      |                ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...