[Snoi2017]英雄联盟
Time Limit: 15 Sec Memory Limit: 512 MBSubmit: 270 Solved: 139
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
4 4 4
2 2 2
Sample Output
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define LL long long const int maxn=125; LL m,f[125][250000];//f[i][j] 到i花了j元的最大展示策略 int k[maxn],c[maxn]; int n; int main() { scanf("%d%lld",&n,&m); for(int i=1;i<=n;i++)scanf("%d",&k[i]); for(int i=1;i<=n;i++)scanf("%d",&c[i]); for(int i=0;i<n;i++) { f[i][0]=1; for(int j=0;j<=(i+1)*2000;j++) if(f[i][j]) { for(int l=0;l<=k[i+1];l++) { LL t; if((double)f[i][j]*(double)l>=(double)m)t=m; else t=(f[i][j]*(LL)(l)); f[i+1][j+l*c[i+1]]=max(max(f[i+1][j+l*c[i+1]],t),f[i][j+l*c[i+1]]); } } } for(int j=0;;j++) if(f[n][j]==m){printf("%d",j);return 0;} }