题解:P13165 [GCJ 2017 #1B] Steed 2: Cruise Control
思路
找那只用时最慢的马,因为 Annie 不希望自己超越其它马。警告:不要找速度最慢的马因为它们的起点不一样。
code
#include <bits/stdc++.h>
using namespace std;
const int N=1e3+10;
struct Horse
{
int v,s;
}hs[N];
double d;
int n;
int main()
{
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
for(int i=1;i<=t;i++)
{
cin>>d>>n;
for(int j=0;j<n;j++)
cin>>hs[j].v>>hs[j].s;
double mmax=0.0;
for(int j=0;j<n;j++)
{
double t=(d-hs[j].v)/hs[j].s;
mmax=max(mmax,t);
}
cout<<"Case #"<<i<<": "<<fixed<<setprecision(6)<<d/mmax<<"\n";
}
return 0;
}