编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#39003 | #1022. jwp的排队难题 | Compile Error | 0 | 0 ms | 0 K | C++ 11 / 873 B | Yanxwb | 2020-07-15 10:00:51 |
#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, int> x, pair<int, int> y) { return y.first * x.second < x.first * y.second; }
const int MAXN = 1e5;
pair<int, int> f[MAXN];
int a[MAXN], b[MAXN];
int main() {
// ios::sync_with_stdio(false);
// cin.tie(0);
int n, i, j;
long long UPD = 0;
// cin >> n;
scanf("%d", &n);
for (i = 0; i < n; ++i) {
// cin >> a[i] >> b[i];
scanf("%d%d", a + i, b + i);
// scanf("%d", b + i);
}
for (i = 0; i < n; ++i) {
f[i] = pair<int, int>(a[i], b[i]);
}
sort(f, f + n, cmp);
long long time = 0;
for (i = 0; i < n; ++i) {
time += f[i].second;
UPD += time * f[i].fist;
// for (j = 0; j <= i; ++j) UPD += f[i].first * f[j].second;
}
// cout << UPD;
printf("%lld", UPD);
return 0;
}
编译信息
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:30:24: error: 'struct std::pair<int, int>' has no member named 'fist'; did you mean 'first'?
UPD+=time*f[i].fist;
^~~~
first
/sandbox/1/a.cpp:16:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
~~~~~^~~~~~~~~~
/sandbox/1/a.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", a + i, b + i);
~~~~~^~~~~~~~~~~~~~~~~~~~~~