Submission #15248057


Source Code Expand

Copy
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

ld p[6] , q[6];

ld get(ld x){
    ld res = 0;
    rep(i , 6)
        res += max(x * p[i] , (1 - x) * q[i]);
    // cout << res << '\n' ;
    return res;
}

void solve()
{
    rep(i , 6){
        cin >> p[i];
        p[i] /= 100. ;
        // cout << p[i] << ' ' ;
    }

    // cout << '\n';
    rep(i , 6){
        cin >> q[i];
        q[i] /= 100. ;

        // cout << q[i] << ' ' ;
    }
    // cout << '\n';
    
    cout << fixed << setprecision(10);
    ld l = 0 , r = 1; 
    rep(_ , 200){
        ld l1 = l + (r - l) / 3 ;
        ld l2 = r - (r - l) / 3 ;
        if(get(l1) >= get(l2)) l = l1;
        else r = l2 ;
    }
    cout << get(l) ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int32_t main(int32_t, char**)’:
./Main.cpp:81:22: warning: unused parameter ‘argc’ [-Wunused-parameter]
   81 | int32_t main(int32_t argc, char *argv[])
      |              ~~~~~~~~^~~~
./Main.cpp:81:34: warning: unused parameter ‘argv’ [-Wunused-parameter]
   81 | int32_t main(int32_t argc, char *argv[])
      |                            ~~~~~~^~~~~~

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 3728 KB
001.txt 3 ms 3736 KB
002.txt 2 ms 3776 KB
003.txt 2 ms 3672 KB
004.txt 2 ms 3664 KB
005.txt 2 ms 3660 KB
006.txt 2 ms 3720 KB
007.txt 3 ms 3660 KB
008.txt 2 ms 3724 KB
009.txt 2 ms 3676 KB
010.txt 2 ms 3744 KB
011.txt 2 ms 3772 KB
012.txt 2 ms 3724 KB
013.txt 1 ms 3800 KB
014.txt 2 ms 3720 KB
015.txt 2 ms 3776 KB
016.txt 2 ms 3796 KB
017.txt 2 ms 3740 KB
018.txt 3 ms 3724 KB
019.txt 2 ms 3772 KB
020.txt 1 ms 3720 KB
021.txt 2 ms 3724 KB
022.txt 2 ms 3720 KB
023.txt 2 ms 3724 KB
024.txt 2 ms 3716 KB
025.txt 2 ms 3672 KB
026.txt 2 ms 3744 KB
027.txt 2 ms 3804 KB
028.txt 2 ms 3812 KB
029.txt 3 ms 3780 KB
030.txt 1 ms 3804 KB
031.txt 3 ms 3740 KB
032.txt 2 ms 3716 KB
033.txt 2 ms 3800 KB
034.txt 2 ms 3736 KB
035.txt 2 ms 3808 KB
036.txt 2 ms 3716 KB
037.txt 2 ms 3720 KB
038.txt 2 ms 3656 KB
example0.txt 2 ms 3728 KB
example1.txt 2 ms 3728 KB