NC14526(购物 )

感受



思路







#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 300 + 10;
const ll mod = 998244353;
int n, m;
int cost[maxn][maxn];
int cnt[maxn];
ll ans;
int main(){
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            scanf("%d", &cost[i][j]);
        }
        sort(cost[i] + 1, cost[i] + m + 1);
    }
    for(int i = 1; i <= n; i++){
        ll res = 1e18, tmp; int id;
        for(int j = 1; j <= i; j++){
            if(cnt[j] == m) continue;
            tmp = (ll)2 * cnt[j] + 1 + cost[j][cnt[j] + 1];
            if(res > tmp){
                res = tmp; id = j;
            }
        }
        cnt[id]++; ans += res;
    }
    printf("%lld\n", ans);
    return 0;
}
全部评论

相关推荐

点赞 评论 收藏
分享
小浪_Coding:找硬件测试,也可兼顾软测欧, 简历还可以的 ,注意排版,项目写的有条理一点, 然后个人技能多加点, 润色好简历之后就开始沟通海投了,深圳,东莞这边做硬件相关的公司还不少, 医疗类,仪器类的都可以尝试
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务