Sicily 1221. 数字游戏

1221. 数字游戏

Constraints

Time Limit: 1 secs, Memory Limit: 32 MB

Description

小W发明了一个游戏,他在黑板上写出了一行数字a1,a2,….an,然后给你m个回合的机会,每回合你可以从中选择一个数擦去它,接着剩下来的每个数字ai都要递减一个值bi。如此重复m个回合,所有你擦去的数字之和就是你所得到的分数。 


 小W和他的好朋友小Y玩了这个游戏,可是他发现,对于每个给出的an和bn序列,小Y的得分总是比他高,所以他就很不服气。于是他想让你帮他算算,对于每个an和bn序列,可以得到的最大得分是多少。这样他就知道有没有可能超过小Y的得分。 

Input

第一行,一个整数n(1<=n<=200),表示数字的个数。

第二行,一个整数m(1<=m<=n),表示回合数。

接下来一行有n个不超过10000的正整数,a1,a2…an,表示原始数字

最后一行有n个不超过500的正整数,b1,b2….bn,表示每回合每个数字递减的值

Output

一个整数,表示最大可能的得分

Sample Input

3 310 20 304 5 6

Sample Output

47

Problem Source

ZSUACM Team Member

// Problem#: 1221
// Submission#: 3294098
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>
#include <string.h>
using namespace std;

struct thing {
    int a, b;
};

thing t[205];
int dp[205][205];

bool cmp(const thing & t1, const thing & t2) {
    return t1.b > t2.b;
}

int main() {

    //std::ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    for (int i = 0; i < n; i++) cin >> t[i].a;
    for (int i = 0; i < n; i++) cin >> t[i].b;
    sort(t, t + n, cmp);

    for (int j = 0; j <= m; j++) dp[0][j] = 0;
    for (int i = 0; i <= n; i++) dp[i][0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= m; j++) {
            dp[i + 1][j] = max(dp[i][j], dp[i][j - 1] + t[i].a - t[i].b * (j - 1));
        }
    }

    cout << dp[n][m] << endl;

    cin >> n;

    return 0;
}                                 


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值