QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#54597 | #4186. Card Trading | Username# | WA | 3ms | 3892kb | C++ | 1.8kb | 2022-10-09 20:00:06 | 2022-10-09 20:00:09 |
Judging History
answer
#ifndef Local
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("popcnt,abm,mmx,avx2")
#endif
#include <bits/stdc++.h>
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
#define sz(x) ((int)(x.size()))
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
#define rep(i, l, r) for (int i = l; i < r; ++i)
using Long = long long;
using Double = double;
using vi = vector<int>;
template <class U, class V>
istream& operator>>(istream& is, pair<U, V>& p) {
is >> p.first >> p.second;
return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
for (auto& x : v) {
is >> x;
}
return is;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
for (auto& x : v) {
os << x << " ";
}
return os;
}
struct Bid {
double price;
double buy;
double sell;
bool operator<(const Bid& other) const { return price < other.price; }
};
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
freopen("test.in", "r", stdin);
freopen("test.out", "w", stdout);
#else
#define endl '\n'
#endif
int n;
cin >> n;
vector<Bid> bids(n);
for (int i = 0; i < n; ++i) {
cin >> bids[i].price >> bids[i].buy >> bids[i].sell;
}
sort(all(bids));
for (int i = 1; i < n; ++i) {
bids[i].sell += bids[i - 1].sell;
}
for (int i = n - 2; i >= 0; --i) {
bids[i].buy += bids[i + 1].buy;
}
int best_price = -1;
double res = 0;
for (int i = 0; i < n; ++i) {
double sales = min(bids[i].buy, bids[i].sell);
if (sales * bids[i].price > res) {
res = sales * bids[i].price;
best_price = i;
}
}
if (best_price == -1) {
cout << "impossible" << endl;
return 0;
}
cout << bids[best_price].price << " " << res << endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3680kb
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: 3ms
memory: 3892kb
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.26 21.04
result:
ok
Test #3:
score: 0
Accepted
time: 2ms
memory: 3760kb
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: 2ms
memory: 3680kb
input:
2 17.10 2 19 29.05 20 11
output:
29.05 581
result:
wrong answer Wrong answer: Price is formatted incorrectly (581).