Submission #534093

#TimeUsernameProblemLanguageResultExecution timeMemory
534093balbitLet's Win the Election (JOI22_ho_t3)C++14
21 / 100
267 ms2360 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define int ll #define pii pair<ll, ll> #define f first #define s second #define REP(i,n) for (int i = 0; i<n; ++i) #define REP1(i,n) for (int i = 1; i<=n; ++i) #define SZ(x) (int)((x).size()) #define ALL(x) (x).begin(), (x).end() #define pb push_back #define MX(a,b) a = max(a,b) #define MN(a,b) a = min(a,b) #ifdef BALBIT #define bug(...) cerr<<"#"<<__LINE__<<" "<<#__VA_ARGS__<<" - ", _do(__VA_ARGS__) template <typename T> void _do( T && x) {cerr<<x<<endl;} template <typename T, typename ...S> void _do( T && x, S && ...y) {cerr<<x<<", "; _do(y...);} #else #define bug(...) #define endl '\n' #endif // BALBIT const int maxn = 500+5; const ll inf = 1ll<<62; int A[maxn], B[maxn]; double dp[maxn][maxn]; ll mnsum[maxn]; signed main(){ ios::sync_with_stdio(0), cin.tie(0); bug(1,2); int n, k; cin>>n>>k; vector<pii> bo(n); REP(i,n) { cin>>bo[i].s>>bo[i].f; if (bo[i].f == -1) bo[i].f = inf; } sort(ALL(bo)); REP1(i,n) { A[i] = bo[i-1].s; B[i] = bo[i-1].f; bug(i,A[i],B[i]); } vector<ll> tmp; for (int i = n; i>=1; --i) { tmp.pb(A[i]); int need = k-i+1; sort(ALL(tmp)); REP(j, need) mnsum[i] += tmp[j]; bug(i, mnsum[i]); } double re = inf; for (int TC = 1; TC <=k; ++TC) { // total number of collaborators + 1 REP(i, maxn) fill(dp[i], dp[i]+maxn, inf); dp[0][1] = 0; REP1(i,n) { REP1(t, TC+1) { if (t>1) MN(dp[i][t], dp[i-1][t-1] + B[i] / (double)(t-1)); MN(dp[i][t], dp[i-1][t] + A[i] / (double)(TC)); } MN(re, dp[i][TC] + mnsum[i+1] / (double)TC); } } cout<<fixed<<setprecision(10)<<re<<endl; }
#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...