QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#136455#4186. Card TradingRetiredButNotTired#WA 1ms3816kbC++171.3kb2023-08-08 19:57:132023-08-08 19:57:14

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-08 19:57:14]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3816kb
  • [2023-08-08 19:57:13]
  • 提交

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