215B - Olympic Medal - CodeForces Solution


greedy math *1300

Please click on ads to support us..

Python Code:


import math

possR1 = list(map(int,input().split()))
n = possR1[0]
possR1 = possR1[1:]

nex = list(map(int,input().split()))
m = nex[0]
possP1 = nex[1:]

possP2 = list(map(int,input().split()))
n = possP2[0]
possP2 = possP2[1:]

A, B = map(int,input().split())

ans = 0
possR1.sort()
possP1.sort()
possP2.sort()
    
r1 = possR1[-1]
p1 = possP1[-1]
p2 = possP2[0]

r2 = math.sqrt((pow(r1,2)*p1*B)/(p2*A + p1*B))
print(r2)

C++ Code:

#include<bits/stdc++.h>
#include <bits/extc++.h>

using namespace std;
#define Triple_A  iostream::sync_with_stdio(false), cin.tie(NULL),cout.tie(NULL);
#define ll long long
#define  ld long double
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define wloop int t; cin>>t; while (t--)
#define f(n) for(int i =0 ; i< n ;i++)
#define END cout<<endl;
#define PI    3.14159265358979323846
#define ordered_set tree<int, null_type,less <int> , rb_tree_tag,tree_order_statistics_node_update>
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define bit(mask,i) ((mask>>i)&1)
typedef pair<ll, ll> iPair;
ll mod =1000000007;
long long mul(long long a, long long b){
    return ((a % mod) * (b % mod))%mod;
}
long long add(long long a, long long b){
    return ((a % mod) + (b % mod)+  mod )%mod;
}
void files() {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
}
ll const N = 1e5 + 5  ;
int fact[N], inv[N];
void pre() {
    fact[0] = inv[0] = 1;
    for (int i = 1; i < N; i++) {
        fact[i] = mul(i, fact[i - 1]);
    }
}

void solve(ll tt = 0) {
     double n , m , k ;
     cin >> n ;
     double r1=INT_MIN;
    for (int i = 0; i < n; ++i) {
        double x;
        cin >> x;
        r1= max(r1,x);
    }
    double p1 =INT_MIN;
    cin >> n ;
    for (int i = 0; i < n; ++i) {
        double x;
        cin >> x;
        p1= max(p1,x);
    }
    double p2 = INT_MAX;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        double x;
        cin >> x;
        p2=min(p2,x);
    }
    double a , b;
    cin >> a >> b;
    double ans = r1 * sqrt((b*p1)/(b*p1+a*p2));
    cout<<fixed<<setprecision(10)<<ans<<endl;

}


int main() {
#ifndef ONLINE_JUDGE
    files();
#endif
    Triple_A
    solve();
}


Comments

Submit
0 Comments
More Questions

133B - Unary
1547A - Shortest Path with Obstacle
624A - Save Luke
1238A - Prime Subtraction
1107C - Brutality
1391B - Fix You
988B - Substrings Sort
312A - Whose sentence is it
513A - Game
1711E - XOR Triangle
688A - Opponents
20C - Dijkstra
1627D - Not Adding
893B - Beautiful Divisors
864B - Polycarp and Letters
1088A - Ehab and another construction problem
1177B - Digits Sequence (Hard Edition)
1155B - Game with Telephone Numbers
1284A - New Year and Naming
863B - Kayaking
1395B - Boboniu Plays Chess
1475D - Cleaning the Phone
617B - Chocolate
1051B - Relatively Prime Pairs
95B - Lucky Numbers
1692D - The Clock
1553D - Backspace
1670D - Very Suspicious
1141B - Maximal Continuous Rest
1341A - Nastya and Rice