标准错误流
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
系统信息
Killed: Segmentation fault
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#46809 | #1077. 1-11B. JM的招摇撞骗 | Runtime Error | 0 | 5 ms | 376 K | C++ 17 / 649 B | 计试001-顾真榕 | 2020-11-30 9:53:35 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int V, tempV, n;
long long maxValue = 0, ans = 0;
vector<int> water = vector<int>(1000000001);
cin >> V >> n;
for (int i = 0; i < n; i++) {
int nowValue, nowVolume;
cin >> nowVolume >> nowValue;
water[nowValue] += nowVolume;
if (nowValue > maxValue)
maxValue = nowValue;
}
for (int i = maxValue; i > 0 && tempV < V; i--) {
if (water[i]) {
int addV = min(V - tempV, water[i]);
tempV += addV;
ans += addV * i;
}
}
cout << ans << endl;
}