QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#54690#4186. Card TradingAs3b_team_f_masr#WA 3ms3884kbC++1.3kb2022-10-10 04:44:102022-10-10 04:44:11

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-10 04:44:11]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3884kb
  • [2022-10-10 04:44:10]
  • 提交

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;
}

详细

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).