Submission #890525

#TimeUsernameProblemLanguageResultExecution timeMemory
890525irmuunLet's Win the Election (JOI22_ho_t3)C++17
11 / 100
1 ms460 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n,k; cin>>n>>k; ll a[n+5],b[n+5],tot=1; for(ll i=1;i<=n;i++){ cin>>a[i]>>b[i]; if(n<=7){ tot=tot*3; } } vector<ll>v1,v2; if(n<=7){ double ans=1e18; for(ll p=0;p<tot;p++){ ll c=p; v1.clear(); v2.clear(); for(ll i=1;i<=n;i++){ if(c%3==1){ v1.pb(a[i]); } if(c%3==2){ if(b[i]>-1){ v2.pb(b[i]); } } c/=3; } sort(all(v1)); sort(all(v2)); double cur=0; for(ll i=0;i<=min((ll)v2.size(),k);i++){ if(i+v1.size()>=k){ double T=0; for(ll j=0;j<k-i;j++){ T+=v1[j]; } ans=min(ans,cur+(double)T/(i+1)); } if(i<v2.size()){ cur+=(double)v2[i]/(i+1); } } } printf("%.10f",ans); return 0; } sort(all(v1)); sort(all(v2)); double ans=1e18; double cur=0; for(ll i=0;i<=min((ll)v2.size(),k);i++){ if(i+v1.size()>=k){ double T=0; for(ll j=0;j<k-i;j++){ T+=v1[j]; } ans=min(ans,cur+(double)T/(i+1)); } if(i<v2.size()){ cur+=(double)v2[i]/(i+1); } } printf("%.10f",ans); }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:45:31: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
   45 |                 if(i+v1.size()>=k){
      |                    ~~~~~~~~~~~^~~
Main.cpp:52:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |                 if(i<v2.size()){
      |                    ~^~~~~~~~~~
Main.cpp:65:23: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
   65 |         if(i+v1.size()>=k){
      |            ~~~~~~~~~~~^~~
Main.cpp:72:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |         if(i<v2.size()){
      |            ~^~~~~~~~~~
#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...