Sponsors

Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2), problem: (C) Voltage Keepsake Solution In C/C++

#include <bits/stdc++.h>

using namespace std;

struct Time {
int i;
double v;
};

const int MAXN = 1e5;
int a[MAXN], b[MAXN];
Time t[MAXN+1];

int main() {
int n, p;
cin >> n >> p;
for (int i = 0; i < n; ++i) {
cin >> a[i] >> b[i];
t[i].v = 1. * b[i] / a[i];
t[i].i = i;
}
sort(t, t+n, [](Time const & a, Time const & b){ return a.v < b.v;});
t[n].v = 1e15;
double sum_a = 0, sum_b = 0, time;
cout.precision(10);
cout << fixed;
for (int i = 0; i < n; ++i) {
int j = t[i].i;
sum_a += a[j];
sum_b += b[j];
time = (1. * sum_b / (sum_a – p));
if(time < t[i+1].v && sum_a > p) {
cout << time;
return 0;
}
}
cout << -1;
}

Ascot Reports Third Quarter...

Ascot Resources Releases Unaudited Third Quarter 2025 Financial Results VANCOUVER,...

First Ikea, now Costco...

Kiwi Property Group Plays Trump Cards with Costco and...

NBC’s “Today” Show Runs...

NBC's Today Show Under Fire for Credulous "Proof" of...

Will Emmvee Photovoltaic IPO...

Emmvee Photovoltaic IPO: A Bright Outlook for Long-Term Solar...

$200 a week and...

Australia's Cost of Living Crisis Pushes International Students to...

Cornell to pay $60M...

Cornell Pays $60 Million to Settle Trump-Era Research Probes E-Blogarithm...

Ascot Reports Third Quarter 2025 Results

Ascot Resources Releases Unaudited Third Quarter 2025 Financial Results VANCOUVER, British Columbia – Ascot Resources Ltd. (TSXV: AOT.H; OTCID: AOTVF) has officially announced its unaudited...

First Ikea, now Costco Wholesale: Kiwi Property Group plays trump cards

Kiwi Property Group Plays Trump Cards with Costco and Ikea Kiwi Property Group (KPG) is strategically reshaping its commercial landscape, making major moves that cement...

NBC’s “Today” Show Runs Credulous Report Claiming “Proof” of Noah’s Ark

NBC's Today Show Under Fire for Credulous "Proof" of Noah’s Ark Report A recent segment on NBC’s venerable Today show has sparked significant criticism within...

Will Emmvee Photovoltaic IPO deliver gains for long-term investors?

Emmvee Photovoltaic IPO: A Bright Outlook for Long-Term Solar Investors? The Indian renewable energy sector continues to shine brightly on the financial markets, and the...

$200 a week and tinned fish: Cost of living hits international students

Australia's Cost of Living Crisis Pushes International Students to the Brink The dream of studying abroad in Australia is quickly turning into a financial nightmare...

Cornell to pay $60M to settle Trump administration probes (Bianca Quilantan/Politico)

Cornell Pays $60 Million to Settle Trump-Era Research Probes E-Blogarithm Exclusive: Cornell University has agreed to a hefty financial resolution, paying $60 million to settle...

Squid Game: The Challenge’s Contestant 100 Talks About That ‘Really Traumatizing Exit’

Contestant 100 Reveals The Truth Behind Her 'Traumatizing Exit' from Squid Game: The Challenge Netflix’s reality competition hit, Squid Game: The Challenge, put its contestants...

Discussion on Covid Vaccination Should Be Non-Controversial

Why the Covid Vaccine Discussion Needs to Shed its Controversy In an age dominated by instantaneous news cycles and the constant pursuit of viral content,...

ISC Declares Quarterly Dividend

Information Services Corporation Declares $0.23 Quarterly Dividend In a significant announcement for its shareholders, Information Services Corporation (TSX:ISC), often referred to simply as "ISC," revealed...