比赛 2016-10-11 4 syz 评测结果 AAAAAAAAAA
题目名称 软件开发 最终得分 100
用户昵称 安呐一条小咸鱼。 运行时间 0.087 s
代码语言 C++ 内存使用 0.36 MiB
提交时间 2016-10-11 19:29:36
显示代码纯文本
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<cstdio>
  4. #include<cstring>
  5. #include<queue>
  6. using namespace std;
  7. const int maxn = 110 ;
  8. int n,tot,a[maxn],b[maxn],f[maxn][maxn],temp,l,r,mid;
  9. bool Dp(int x)
  10. {
  11. memset(f,-0x3f,sizeof(f));
  12. f[0][0]=0;
  13. for(int i=1;i<=n;i++)
  14. {
  15. for(int j=0;j<=tot;j++)
  16. {
  17. for(int k=0;k<=j;k++)
  18. {
  19. if(x < k * a[i] )continue;
  20. f[i][j]=max( f[i][j] , f[i-1][j-k] + ( x- k * a[i] ) / b[i] );
  21. }
  22. }
  23. }
  24. if(f[n][tot]<tot)return false;
  25. return true;
  26. }
  27. int main()
  28. {
  29. freopen("time.in","r",stdin);
  30. freopen("time.out","w",stdout);
  31. scanf("%d%d",&n,&tot);
  32. for(int i=1;i<=n;i++){
  33. scanf("%d%d",&a[i],&b[i]);
  34. temp=max(temp,max(a[i],b[i]));
  35. }
  36. l=1,r=temp*tot*8;
  37. while(l<r){
  38. int mid=(l+r)/2;
  39. if(Dp(mid))r=mid;
  40. else l=mid+1;
  41. }
  42. printf("%d\n",l);
  43. }