用户输出
590
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#80625 | #1077. 1-11B. JM的招摇撞骗 | Wrong Answer | 0 | 2 ms | 268 K | C++ 17 / 694 B | 15291309895 | 2022-07-18 22:56:26 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 7;
struct water {
int a, b;
} Water[MAXN];
bool compare(water x, water y) { return x.b > y.b; }
ll minx(ll x, ll y) { return x > y ? y : x; }
ll V, n, ans = 0;
int main() {
cin >> V >> n;
for (int i = 0; i < n; i++) cin >> Water[i].a >> Water[i].b;
sort(Water, Water + n, compare);
int cnt = 0;
for (int i = 0; i < n; i++) {
if (V == 0)
break;
if (V - Water[i].a > 0) {
ans += (minx(Water[i].a, V)) * Water[i].b;
V -= Water[i].b;
}
if (i == n - 1)
break;
}
cout << ans;
return 0;
}