Submission #549668

#TimeUsernameProblemLanguageResultExecution timeMemory
549668cpp219Let's Win the Election (JOI22_ho_t3)C++17
10 / 100
9 ms364 KiB
#include<bits/stdc++.h> #define ll long long #define ld long double #define fs first #define sc second #define debug(y) cout<<y,exit(0) using namespace std; typedef pair<ll,ll> LL; const ll N = 500 + 9; const ll inf = 1e18 + 7; ld ans = inf*1.0; ll n,k,collab; LL a[N]; bool lf(LL x,LL y){ return x.sc < y.sc; } int main(){ ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0); #define task "tst" if (fopen(task".inp","r")){ freopen(task".inp","r",stdin); //freopen(task".out","w",stdout); } cin>>n>>k; for (ll i = 1;i <= n;i++){ cin>>a[i].fs>>a[i].sc; if (a[i].sc == -1) a[i].sc = inf; collab += (a[i].sc != -1); } sort(a + 1,a + n + 1,lf); for (ll take = 0;take <= min(k,collab);take++){ ll man = 1; ld tmp = 0; vector<LL> rm; for (ll i = 1;i <= take;i++){ tmp += (ld)a[i].sc/man; man++; } for (ll i = take + 1;i <= n;i++) rm.push_back(a[i]); sort(rm.begin(),rm.end()); for (ll i = 0;i < k - take;i++) tmp += (ld) rm[i].fs/man; ans = min(ans,tmp); //debug(tmp); } cout<<fixed<<setprecision(6)<<ans; } /// be confident

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...