Submission #534778

#TimeUsernameProblemLanguageResultExecution timeMemory
534778WitherLet's Win the Election (JOI22_ho_t3)C++14
10 / 100
9 ms332 KiB
#include <bits/stdc++.h> #define For(i,a,b) for(int i=a;i<=b;i++) #define Forr(i,a,b) for(int i=a;i>=b;i--) #define Fors(i,a,b,s) for(int i=a;i<=b;i+=s) #define F first #define S second #define sz(x) ((int)x.size()) #define all(x) x.begin(),x.end() #define eb emplace_back #define INF (ll)(9e18) #define endl '\n' #define int double using namespace std; using pii=pair<int,int>; int32_t main(){ ios::sync_with_stdio(false); cin.tie(0); set<int> data; int N,K; cin>>N>>K;; vector<pii> cty; vector<pii> clb; int c=0; for (int i=0;i<N;i++){ pii temp; cin>>temp.F; temp.S=i; cty.push_back(temp); cin>>temp.F; if (temp.F!=-1){ clb.push_back(temp); c+=1; } } sort(cty.begin(),cty.end()); sort(clb.begin(),clb.end()); // for (int i=0;i<N;i++){ // cout<<cty[i].F<<" "<<cty[i].S<<endl; // } // // for (int i=0;i<c;i++){ // cout<<clb[i].F<<" "<<clb[i].S<<endl; // } int ans=0; for (int i=0;i<K;i++){ ans+=cty[i].F; } // cout<<min((int)c,(int)(K-1)); cout<<endl; if (c==0){ cout<<ans; } else{ int temp=1; int ansss=0; int ub=min((int)c,(int)(K-1)); for (int i=0;i<ub;i++){ ansss+=(clb[i].F)/temp; temp+=1; int anss=ansss; data.insert(clb[i].S); int pn=temp-1; int ct=0; int id=0; while (id<K-pn){ if (data.count(cty[ct].S)){ ct+=1; continue; } else{ anss+=cty[ct].F/temp; ct+=1; id+=1; } } if (anss<ans){ ans=anss; } } cout<<ans; } }
#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...