比赛 20241024 评测结果 AAAAA
题目名称 最佳课题选择 最终得分 100
用户昵称 darkMoon 运行时间 0.020 s
代码语言 C++ 内存使用 3.60 MiB
提交时间 2024-10-24 08:29:42
显示代码纯文本
#include<bits/stdc++.h>
#define int long long
using namespace std;
auto IN = freopen("topic.in", "r", stdin);
auto OUT = freopen("topic.out", "w", stdout);
auto mread = [](){int x;scanf("%lld", &x);return x;};
const int N = 205, M = 25;
int n = mread(), m = mread(), a[M], b[M], f[M][N];
int mi(int x, int k){
    int ans = 1;
    for(int i = 1; i <= k; i ++){
        ans *= x;
    }
    return ans;
}
signed main(){
    for(int i = 1; i <= m; i ++){
        cin >> a[i] >> b[i];
    }
    memset(f, 0x3f, sizeof(f));
    f[0][0] = 0;
    for(int i = 1; i <= m; i ++){
        f[i][0] = 0;
        for(int j = 1; j <= n; j ++){
            for(int k = 0; k <= j; k ++){
                f[i][j] = min(f[i][j], f[i - 1][j - k] + a[i] * mi(k, b[i]));
            }
        }
    }
    printf("%lld\n", f[m][n]);
    return 0;
}