Submission #703469

#TimeUsernameProblemLanguageResultExecution timeMemory
703469niterLet's Win the Election (JOI22_ho_t3)C++14
10 / 100
29 ms308 KiB
#include <bits/stdc++.h> #define loop(i,a,b) for(int i=a;i<b;i++) #define pii pair<int,int> #define ff first #define ss second #define mp make_pair #define pb push_back #define STL(i, x) for(auto &i:x) cout << i << " "; cout << "\n"; #define iNf 2147483647 using namespace std; ostream& operator<<(ostream &os, pii XXX){ cout << "[" << XXX.ff << ", " << XXX.ss << "]"; } void db(){ cout << "\n"; } template<class T, class ...U> void db(T XXX, U ...YYY){ cout << XXX; db(YYY...); } bool cmp_ff(pii XXX, pii YYY){ return (XXX.ff != YYY.ff) ? (XXX.ff < YYY.ff) : (XXX.ss < YYY.ss); } bool cmp_ss(pii XXX, pii YYY){ return (XXX.ss != YYY.ss) ? (XXX.ss < YYY.ss) : (XXX.ff > YYY.ff); } int main(){ int n, k; cin >> n >> k; int a[505], b[505]; vector<pii> org(n), dp; loop(i,0,n){ cin >> a[i] >> b[i]; if(b[i] == -1) b[i] = iNf; org[i] = mp(a[i], b[i]); } long double ans = (1e300), tmp_ans; int tmp_get, tmp_now, sum = 0; loop(i,0,k+1){ dp = org; tmp_ans = 0; tmp_get = 0; tmp_now = 1; sort(dp.begin(), dp.end(), cmp_ss); loop(j,0,i){ if(dp[j].ss == iNf) break; tmp_ans += (long double)dp[j].ss / tmp_now; dp[j].ff = iNf; tmp_get++; tmp_now++; } sort(dp.begin(), dp.end(), cmp_ff); sum = 0; loop(j,0,n){ sum += dp[j].ff; tmp_get++; if(tmp_get == k){ ans = min(ans, tmp_ans + (long double)sum / tmp_now); break; } } } cout << fixed << setprecision(10) << ans << "\n"; return 0; } /* 3 3 1 5 2 3 4 5 */

Compilation message (stderr)

Main.cpp: In function 'std::ostream& operator<<(std::ostream&, std::pair<int, int>)':
Main.cpp:14:1: warning: no return statement in function returning non-void [-Wreturn-type]
   14 | }
      | ^
#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...