QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#54690 | #4186. Card Trading | As3b_team_f_masr# | WA | 3ms | 3884kb | C++ | 1.3kb | 2022-10-10 04:44:10 | 2022-10-10 04:44:11 |
Judging History
answer
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
typedef long double ld;
typedef long long ll;
using namespace std;
int di[] = {1, 0, -1, -1, 0, 1, -1, 1};
int dj[] = {1, 1, 0, -1, -1, 0, 1, -1};
const ll oo = 1e18, MOD = 998244353;
const int N = 1e5 + 5, M = 350;
const ld PI = acos(-1.0), EPS = 1e-9;
int n;
pair<double, pair<int, int> > p[N];
int l[N], r[N];
double ans = 0;
//#define endl '\n'
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//freopen("farm.in", "r", stdin);
//memset(dp, -1, sizeof dp);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> p[i].first >> p[i].second.first >> p[i].second.second;
}
sort(p + 1, p + n + 1);
for (int i = 1; i <= n; i++) l[i] = p[i].second.first, r[i] = p[i].second.second;
for (int i = n; i >= 1; i--) l[i] += l[i + 1];
for (int i = 1; i <= n; i++) r[i] += r[i - 1];
int idx = 0;
for (int i = 1; i <= n; i++) {
if (l[i] > 0 && r[i] > 0) {
double tmp = p[i].first * min(l[i], r[i]);
if (tmp > ans) ans = tmp, idx = i;
}
}
if (idx) cout << p[idx].first << " " << ans;
else cout << "impossible";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 3884kb
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: 2ms
memory: 3804kb
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: 1ms
memory: 3752kb
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: 1ms
memory: 3788kb
input:
2 17.10 2 19 29.05 20 11
output:
29.05 581
result:
wrong answer Wrong answer: Price is formatted incorrectly (581).