rt。【赏关】站外题样例已过WA89pts带思路码风不离谱求调求hack


#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n, m, a[200], b[200], ans;
struct paper{
int type, id, cost;
bool operator<(const paper q)const{
return q.cost < cost;
}
};
priority_queue<paper> q;
int main(){
cin >> m >> n;
for(int i = 0; i < n; i++){
cin >> a[i] >> b[i];
paper t;
t.type = i;
t.id = 1;
t.cost = a[i];
q.push(t);
}
for(int i = 0; i < m; i++){
ans += q.top().cost;
int t = q.top().type, s = q.top().id;
q.pop();
paper p;
p.cost = a[t] * pow(s + 1, b[t]) - a[t] * pow(s, b[t]);
p.id = s + 1;
p.type = t;
q.push(p);
}
cout << ans << endl;
return 0;
}
思路:用优先队列存每增加一篇所需的花费,贪心,每次都取最便宜的论文