Submission #834013

#TimeUsernameProblemLanguageResultExecution timeMemory
834013LeVanThucLet's Win the Election (JOI22_ho_t3)C++17
10 / 100
5 ms356 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define p(x,y) pair<ll,ll>(x,y) #define BIT(i,x) ((x>>i)&1) #define MASK(x) (1<<x) #define ld long double #define __builtin_popcount __builtin_popcountll #define pll pair<ll,ll> template<class T1,class T2> bool maximize(T1 &x,const T2 &y) { if(x<y) { x=y; return 1; } return 0; } template<class T1,class T2> bool minimize(T1 &x,const T2 &y) { if(x>y) { x=y; return 1; } return 0; } void online() { std::ios_base::sync_with_stdio(0); cin.tie(0); #ifdef thuc freopen("input.inp", "r", stdin); freopen("output.out","w", stdout); #else #endif } const ll N=1e6+10; pll a[N]; ll n,k; bool cmp2(pll a,pll b) { return a.se==b.se?a.fi<b.fi:a.se<b.se; } int main() { online(); cin>>n>>k; for(int i=1;i<=n;i++) { cin>>a[i].fi>>a[i].se; if(a[i].se==-1) a[i].se=1e12; } sort(a+1,a+n+1,cmp2); ld ans=1e18; ld base=0; for(ll i=0;i<=k;i++) { vector<ll> vt; if(i>0) base+=(ld)a[i].se/(ld)i; ld cr=base; for(int j=i+1;j<=n;j++) { vt.push_back(a[j].fi); } sort(vt.begin(),vt.end()); for(int j=0;j<k-i;j++) { ll z=vt[j]; cr+=(ld)vt[j]/(ld)(i+1); } minimize(ans,cr); } cout<<fixed<<setprecision(10)<<ans; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:74:16: warning: unused variable 'z' [-Wunused-variable]
   74 |             ll z=vt[j];
      |                ^
#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...