Submission #15241839


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
using Int = long long;
int main() {
    double P[6], Q[6];
    for (auto &p : P) cin >> p, p /= 100;
    for (auto &q : Q) cin >> q, q /= 100;
    auto f = [&](double x) {
        double ans = 0;
        for (int i = 0; i < 6; i++) {
            ans += max(P[i] * x, Q[i] * (1 - x));
        }
        return ans;
    };
    double lo = 0, hi = 1.0;
    for (int i = 0; i < 100; i++) {
        double a = (2 * lo + hi) / 3;
        double b = (lo + 2 * hi) / 3;
        if (f(a) >= f(b)) {
            lo = a;
        } else {
            hi = b;
        }
    }
    cout << f(lo) << endl;
    return 0;
}

Submission Info

Submission Time
Task D - Dice Game
User ha15
Language C++ (GCC 9.2.1)
Score 1000
Code Size 876 Byte
Status
Exec Time 8 ms
Memory 3804 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 example0.txt, example1.txt
All 1000 / 1000 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt 8 ms 3780 KB
001.txt 3 ms 3656 KB
002.txt 2 ms 3780 KB
003.txt 2 ms 3784 KB
004.txt 2 ms 3780 KB
005.txt 2 ms 3752 KB
006.txt 2 ms 3752 KB
007.txt 2 ms 3800 KB
008.txt 2 ms 3664 KB
009.txt 2 ms 3804 KB
010.txt 2 ms 3724 KB
011.txt 2 ms 3760 KB
012.txt 2 ms 3652 KB
013.txt 2 ms 3708 KB
014.txt 4 ms 3800 KB
015.txt 2 ms 3780 KB
016.txt 2 ms 3664 KB
017.txt 2 ms 3740 KB
018.txt 2 ms 3764 KB
019.txt 2 ms 3704 KB
020.txt 3 ms 3792 KB
021.txt 2 ms 3644 KB
022.txt 2 ms 3804 KB
023.txt 2 ms 3704 KB
024.txt 2 ms 3728 KB
025.txt 2 ms 3648 KB
026.txt 2 ms 3728 KB
027.txt 2 ms 3648 KB
028.txt 2 ms 3792 KB
029.txt 2 ms 3648 KB
030.txt 2 ms 3728 KB
031.txt 2 ms 3788 KB
032.txt 2 ms 3804 KB
033.txt 8 ms 3652 KB
034.txt 2 ms 3648 KB
035.txt 2 ms 3712 KB
036.txt 2 ms 3736 KB
037.txt 3 ms 3664 KB
038.txt 2 ms 3792 KB
example0.txt 2 ms 3712 KB
example1.txt 1 ms 3740 KB