编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#13611 | #1077. 1-11B. JM的招摇撞骗 | Compile Error | 0 | 0 ms | 0 K | C++ 17 / 758 B | maki49 | 2019-07-07 10:54:43 |
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 2e5 + 5;
struct water(ll a, ll b) {
ll volume = a;
ll value = b;
};
bool cmp(water A, water B) {
return A.value > B.value; //价值降序
}
water w[maxn];
int main() {
ll V, n;
cin >> V >> n;
ll ans = 0;
for (int i = 1; i <= n; i++) {
cin >> w[i].volume >> w[i].price;
}
sort(w, w + n, cmp);
while (V) {
for (int i = 1; i <= n; i++) {
if (V > w[i].volume) {
V -= w[i].volume;
ans += w[i].volume * w[i].price;
} else {
V = 0;
ans += V * w[i].price;
}
}
}
cout << ans << endl;
return 0;
}
编译信息
/sandbox/1/a.cpp:11:16: error: expected ')' before 'a'
struct water(ll a, ll b) {
~ ^~
)
/sandbox/1/a.cpp:15:16: error: 'A' has incomplete type
bool cmp(water A, water B) {
~~~~~~^
/sandbox/1/a.cpp:11:8: note: forward declaration of 'struct water'
struct water(ll a, ll b) {
^~~~~
/sandbox/1/a.cpp:15:25: error: 'B' has incomplete type
bool cmp(water A, water B) {
~~~~~~^
/sandbox/1/a.cpp:11:8: note: forward declaration of 'struct water'
struct water(ll a, ll b) {
^~~~~
/sandbox/1/a.cpp:18:7: error: elements of array 'water w [200005]' have incomplete type
water w[maxn];
^
/sandbox/1/a.cpp:18:7: error: storage size of 'w' isn't known