QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#234458 | #4186. Card Trading | Fyind# | WA | 0ms | 3960kb | C++17 | 1.2kb | 2023-11-01 17:27:23 | 2023-11-01 17:27:23 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp(x, y) make_pair(x, y)
int main() {
int n;
scanf("%d", &n);
ll ans = -1, pos;
vector<pair<ll, pair<ll, ll>>> a(n + 1); // p, b, s
ll sumb = 0, sums = 0;
for (int i = 1; i <= n; ++i) {
ll x, y;
scanf("%lld.%lld %lld %lld", &x, &y, &a[i].se.fi, &a[i].se.se);
a[i].fi = x * 100 + y;
}
sort(a.begin() + 1, a.end());
for (int i = 1; i <= n; ++i)
sumb += a[i].se.fi;
for (int i = 1; i <= n; ++i) {
int cur = i;
sums += a[cur].se.se;
while (cur <= n && a[cur + 1].fi == a[cur].fi)
sums += a[++cur].se.se;
// cout << i << ':' << sums << ' ' << sumb << endl;
if (1ll * a[i].fi * min(sums, sumb) > ans)
ans = 1ll * a[i].fi * min(sums, sumb), pos = a[i].fi;
for (int j = i; j <= cur; ++j)
sumb -= a[i].se.fi;
i = cur;
}
if (ans == -1) {
cout << "impossible" << '\n';
}
else
cout << pos / 100 << '.' << pos % 100 << ' ' << ans / 100 << '.' << ans % 100 << '\n';
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3960kb
input:
5 12.00 0 3 11.99 2 0 11.98 5 0 10.00 1 0 12.01 0 6
output:
10.0 0.0
result:
wrong answer Wrong answer: Price is formatted incorrectly (10.0).