Submission #933335

#TimeUsernameProblemLanguageResultExecution timeMemory
933335koukirocksLet's Win the Election (JOI22_ho_t3)C++17
10 / 100
13 ms4696 KiB
#include <bits/stdc++.h> #define speed ios_base::sync_with_stdio(0); cin.tie(0) #define all(x) (x).begin(),(x).end() using namespace std; typedef long long ll; typedef double db; typedef long double ldb; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll MAX=5e2+10,P=998244353; const ll INF=0x3f3f3f3f,oo=0x3f3f3f3f3f3f3f3f; ll n,k; pair<ldb,ldb> vt[MAX]; ldb dp[MAX][MAX]; int main() { speed; cin>>n>>k; for (int i=1;i<=n;i++) { cin>>vt[i].first>>vt[i].second; } sort(vt+1,vt+n+1,[=](pair<ldb,ldb> a,pair<ldb,ldb> b){ if (a.second==-1) a.second=oo; if (b.second==-1) b.second=oo; return a.second<b.second; }); for (int i=1;i<=k;i++) dp[0][i]=oo; dp[0][0]=0; for (int i=1;i<=n;i++) { dp[i][0]=0; for (int j=1;j<=k;j++) { if (vt[i].second==-1) dp[i][j]=dp[i-1][j]; else dp[i][j]=min(dp[i-1][j-1]+vt[i].second/j,dp[i-1][j]); // cout<<dp[i][j]<<" "; } // cout<<"\n"; } ldb ans=oo; for (int i=0;i<=n;i++) { vector<ldb> rest; for (int j=i+1;j<=n;j++) rest.push_back(vt[j].first); sort(all(rest)); ldb ttl=0; for (int j=k;j>=0;j--) { ans=min(ans,dp[i][j]+ttl/(j+1)); // cout<<i<<" "<<j<<" "<<dp[i][j]<<" "<<ttl<<"\n"; if (k-j>=rest.size()) break; ttl+=rest[k-j]; } // cout<<"\n"; } cout<<fixed<<setprecision(20)<<ans<<"\n"; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:50:11: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |    if (k-j>=rest.size()) break;
      |        ~~~^~~~~~~~~~~~~
#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...