QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#185202 | #4186. Card Trading | rgnerdplayer# | WA | 0ms | 3816kb | C++20 | 1.4kb | 2023-09-21 18:54:35 | 2023-09-21 18:54:36 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
auto solve = [&]() {
int n;
cin >> n;
auto readDouble = [&]() {
int x, y;
char dot;
cin >> x >> dot >> y;
return x * 100 + y;
};
auto writeDouble = [&](i64 x) {
cout << x / 100 << '.';
cout << setw(2) << setfill('0') << x % 100;
};
vector<array<int, 3>> a(n);
for (auto &[p, b, s] : a) {
p = readDouble();
cin >> b >> s;
}
sort(a.begin(), a.end());
vector<int> pref(n + 1), suf(n + 1);
for (int i = 0; i < n; i++) {
pref[i + 1] = pref[i] + a[i][2];
}
for (int i = n - 1; i >= 0; i--) {
suf[i] = suf[i + 1] + a[i][1];
}
int price = -1;
i64 best = 0;
for (int i = 1; i < n; i++) {
int p = a[i][0];
i64 res = 1LL * p * min(pref[i], suf[i]);
if (res > best) {
best = res;
price = p;
}
}
if (best == 0) {
cout << "impossible\n";
return;
}
writeDouble(price);
cout << ' ';
writeDouble(best);
cout << '\n';
};
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3588kb
input:
5 12.00 0 3 11.99 2 0 11.98 5 0 10.00 1 0 12.01 0 6
output:
impossible
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
6 2.85 14 0 4.50 0 1 5.26 3 3 6.17 1 0 14.78 0 2 21.04 1 0
output:
21.04 21.04
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
6 2.85 14 0 4.50 0 1 5.26 2 3 14.78 0 2 1.83 0 1 21.04 1 0
output:
21.04 21.04
result:
ok
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3808kb
input:
2 17.10 2 19 29.05 20 11
output:
29.05 551.95
result:
wrong answer Wrong answer: Author price / turnover mismatch (Only 20 fulfilled orders for a total turnover of 581.00 instead of 551.95).