Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- //freopen("test.in" , "r" ,stdin);
- double a;
- double b;
- double distance[1024];
- double speed[1024];
- double max = 100;
- while(cin >>a , cin >>b){
- //cout <<a << " " << b << endl;
- double small;
- double infinity;
- double old;
- for(int i=0;i<a;i++){
- cin >> distance[i];
- cin >> speed[i];
- //cout << "C : " << c[i] << " ";
- //cout << "D : " << d[i] << endl;
- small = min(old,speed[i]);
- old = speed[i];
- // cout << "SMALL : " << small << endl;
- }
- small = -small;
- infinity = 0x3f3f3f3f;
- for(int j = 0; j < max; j++) {
- double check = (small+infinity)/2;
- double sum = 0;
- for (int k = 0; k < a && sum < b; k++)
- sum += distance[k] / (check + speed[k]);
- if (sum > b){
- small = check;
- }
- else{
- infinity = check;
- }
- }
- cout << fixed <<setprecision(9) << small << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement