Submission #638708

#TimeUsernameProblemLanguageResultExecution timeMemory
638708jamezzzLet's Win the Election (JOI22_ho_t3)C++17
10 / 100
1351 ms1004540 KiB
#include <bits/stdc++.h> using namespace std; #define pf printf #define sf scanf typedef long long ll; typedef pair<int,int> ii; #define maxn 505 #define INF 1023456789 int n,k,a[maxn],b[maxn]; vector<ii> v; double memo[maxn+5][maxn+5][maxn+5]; double dp(int pos,int ppl,int vote){ if(pos==n){ if(vote>=k)return 0; else return INF; } if(memo[pos][ppl][vote]>=0)return memo[pos][ppl][vote]; double ans=INF; //case 1: dont take ans=min(ans,dp(pos+1,ppl,vote)); //case 2: just get vote ans=min(ans,dp(pos+1,ppl,vote+1)+(double)a[pos]/(ppl+1)); //case 3: get new person if(b[pos]!=INF)ans=min(ans,dp(pos+1,ppl+1,vote+1)+(double)b[pos]/(ppl+1)); //pf("%d %d %d: %f\n",pos,ppl,vote,ans); return memo[pos][ppl][vote]=ans; } int main(){ sf("%d%d",&n,&k); for(int i=0;i<n;++i){ int x,y; sf("%d%d",&x,&y); if(y==-1)y=INF; v.push_back({y,x}); } sort(v.begin(),v.end()); for(int i=0;i<n;++i){ tie(b[i],a[i])=v[i]; } for(int i=0;i<=n;++i){ for(int j=0;j<=n;++j){ for(int l=0;l<=n;++l){ memo[i][j][l]=-1; } } } pf("%f\n",dp(0,0,0)); }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:34:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |  sf("%d%d",&n,&k);
      |    ^
Main.cpp:37:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |   sf("%d%d",&x,&y);
      |     ^
#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...