Loading

AtCoder-abc258_d Trophy

Trophy

贪心

打游戏的时候都知道,解锁前置关卡,直到打到收益最高的关卡就一直刷副本

因此答案肯定是解锁完前置关卡就不断刷,找到最小值就行

巨大坑:初始值一定要很大很大(不会有人因此 wa 了 3 发吧)

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <deque>
#include <stack>
using namespace std;
typedef unsigned long long ll;
#define pii pair<int, int>
const ll maxn = 2e5 + 10;
const ll inf = 4e18 + 10;
ll a[maxn], b[maxn];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, m;
    cin >> n >> m;
    for(int i=0; i<n; i++)
        cin >> a[i] >> b[i];
    ll ans = inf, temp = 0;
    for(int i=0; i<n && m; i++)
    {
        m--;
        temp += a[i] + b[i];
        ans = min(ans, temp + b[i] * m);
    }
    cout << ans << endl;
    return 0;
}
posted @ 2022-07-04 15:30  dgsvygd  阅读(110)  评论(0编辑  收藏  举报