Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <set>
- #include <vector>
- #include <stack>
- #include <algorithm>
- #include <iomanip>
- using namespace std;
- long long n;
- long double w,h;
- pair<long double,long double> a[111111];
- bool check(long double k){
- long double tekh=k*a[0].second;
- long double tekw=w;
- long double osth=h;
- for (int i=0; i<n; i++){
- long double tekx=k*a[i].first;
- long double teky=k*a[i].second;
- if (tekw-tekx>=0 && teky==tekh && i!=0) {
- tekw-=tekx;
- }
- else {
- if (osth-teky<0) return false;
- if (w-tekx<0) return false;
- osth-=teky,tekh=teky,tekw=w-tekx;
- }
- }
- return true;
- }
- int main(){
- cin>>n>>w>>h;
- for (int i=0; i<n; i++)
- cin>>a[i].first>>a[i].second;
- long double l=0;
- long double r=111111111;
- long double mid=(l+r)/2;
- for (int i=0; i<55; i++){
- if (check(mid)==false) {
- r=mid;
- }
- else {
- l=mid;
- }
- mid=(l+r)/2;
- }
- setprecision(10);
- cout<<fixed<<mid<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement