QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#136455 | #4186. Card Trading | RetiredButNotTired# | WA | 1ms | 3816kb | C++17 | 1.3kb | 2023-08-08 19:57:13 | 2023-08-08 19:57:14 |
Judging History
answer
// Hey there.. I love you <3
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
mt19937 rnd(time(nullptr));
const int N = 1e5 + 5, mod = 1e9 + 7;
const double pi = acos(-1), eps = 1e-10;
int n;
tuple<double, int, int> prices[N];
void work() {
cin >> n;
ll bSum = 0;
for (int i = 0; i < n; ++i) {
double p;
int b, s;
cin >> p >> b >> s;
bSum += b;
prices[i] = {p, b, s};
}
sort(prices, prices + n);
ll sSum = 0;
double maxSum = 0, bestP = -1;
for (int i = 0; i < n; ++i) {
sSum += get<2>(prices[i]);
double curSum = min(bSum, sSum) * get<0>(prices[i]);
if (curSum > maxSum) maxSum = curSum, bestP = get<0>(prices[i]);
bSum -= get<1>(prices[i]);
}
if (bestP == -1)
cout << "impossible" << endl;
else
cout << fixed << setprecision(12) << bestP << " " << maxSum << endl;
}
void init() {
cin.tie(nullptr);
istream::sync_with_stdio(false);
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
}
int main() {
init();
int testCases = 1;
// cin >> testCases;
while (testCases--) work();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3804kb
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: -100
Wrong Answer
time: 1ms
memory: 3816kb
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:
5.260000000000 21.040000000000
result:
wrong answer Wrong answer: Price is formatted incorrectly (5.260000000000).