Selling CPUs

        2789: Selling CPUs
 时间限制: 1 Sec  内存限制: 64 MB

题目描述
You are very happy, that you got a job at ACME Corporation’s CPU factory. After a hard month of labor, your boss has given you c identical CPUs as payment. Apparently, ACME Corporation is low on cash at the moment.
Since you can’t live on CPUs alone, you want to sell them on the market and buy living essentials from the money you make. Unfortunately, the market is very restrictive in the way you are allowed to conduct business. You are only allowed to enter the market once, you can only trade with each merchant once, and you have to visit the traders in a specific order. The market organizers have marked each merchant with a number from 1 to m (the number of merchants) and you must visit them in this order. Each trader has his own price for every amount of CPUs to buy.

输入The input consists of:
• one line with two integers c and m (1 ≤ c, m ≤ 100), where c is the number of CPUs and m is the number of merchants;
• m lines describing the merchants. Each merchant is described by:
– one line with c integers p 1 , . . . , p c (1 ≤ p i ≤ 10 5 for all 1 ≤ i ≤ c), where p i is the amount of money the merchant will give you for i CPUs.

输出Output the maximum amount of money you can make by selling the CPUs you have.
Note that you don’t have to sell all CPUs.

样例输入5 3
1 4 10 1 1
1 1 8 1 1
1 1 9 1 1

样例输出
13

    > #include<bits/stdc++.h> 
    > using namespace std; const int maxn = 103;
    >  int c,m,ans=0; i
    >  nt cost[maxn][maxn]; 
    >  int dp[maxn][maxn];   //dp[i][j]储存在第i个商家时,已经销售了j个CPU最大值 
    > void solve()
      {
    >     for(int i=0;i<=c;i++)  //在第一个位置时,每一个都是最大值
    > 
    >     {
    >         dp[1][i] = cost[1][i];   
    >         ans = max(ans,dp[1][i]);
    >     }
    >     for(int i=2;i<=m;i++)
    >     {
    >         for(int j=1;j<=c;j++)  // 求在第i个商家时,销售j个cpu的最大值
    >         {
    >             for(int k=0;k<=j;k++)  //枚举最大值
    >             {
    >                 dp[i][j] = max(dp[i][j],dp[i-1][j-k]+cost[i][k]);
    >             }
    >             ans=max(ans,dp[i][j]);
    >         }
    >     } 
     }
      int main() 
      {
    >     scanf("%d%d",&c,&m);
    >     for(int i=1;i<=m;i++)
    >     {
    >         for(int j=1;j<=c;j++)
    >             scanf("%d",&cost[i][j]);
    >     }
    >     solve();
    >     cout<<ans; 
     }
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
毕业设计,基于SpringBoot+Vue+MySQL开发的海滨体育馆管理系统,源码+数据库+毕业论文+视频演示 本基于Spring Boot的海滨体育馆管理系统设计目标是实现海滨体育馆的信息化管理,提高管理效率,使得海滨体育馆管理工作规范化、高效化。 本文重点阐述了海滨体育馆管理系统的开发过程,以实际运用为开发背景,基于Spring Boot框架,运用了Java技术和MySQL作为系统数据库进行开发,充分保证系统的安全性和稳定性。本系统界面良好,操作简单方便,通过系统概述、系统分析、系统设计、数据库设计、系统测试这几个部分,详细的说明了系统的开发过程,最后并对整个开发过程进行了总结,实现了海滨体育馆相关信息管理的重要功能。 本系统的使用使管理人员从繁重的工作中解脱出来,实现无纸化办公,能够有效的提高海滨体育馆管理效率。 关键词:海滨体育馆管理,Java技术,MySQL数据库,Spring Boot框架 本基于Spring Boot的海滨体育馆管理系统主要实现了管理员功能模块和学生功能模块两大部分,这两大功能模块分别实现的功能如下: (1)管理员功能模块 管理员登录后可对系统进行全面管理操作,包括个人中心、学生管理、器材管理、器材借出管理、器材归还管理、器材分类管理、校队签到管理、进入登记管理、离开登记管理、活动预约管理、灯光保修管理、体育论坛以及系统管理。 (2)学生功能模块 学生在系统前台可查看系统信息,包括首页、器材、体育论坛以及体育资讯等,没有账号的学生可进行注册操作,注册登录后主要功能模块包括个人中心、器材管理、器材借出管理、器材归还管理、校队签到管理、进入登记管理、离开登记管理、活动预约管理。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lighting_yang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值