这题不能二分...或许能二分也要讨论很多...
所以可以直接贪心...
直接算出平均的水温,再分类讨论一下即可,假如平均的水温比n个杯子里的都小,那么肯定大水缸是降温的.假如平均的水温比最大的要大,说明大水缸是升温的,不然我的大水缸的温度夹在两个max和min中间,那么一定是不能调节的..
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
double t[N],c[N];
int main()
{
double T,C;
int n;
cin>>n;
cin>>T>>C;
double v=0.0;
v+=T*C;
double tmx=0.0,tmi=1e9,c1=C;
for(int i=1;i<=n;i++)
{
cin>>t[i]>>c[i];
v+=t[i]*c[i];
c1+=c[i];
tmx=max(t[i],tmx);
tmi=min(t[i],tmi);
}
double temp=v/c1;
if(temp<=tmi)//假如合并更小.
{
puts("Possible");
printf("%.4f\n",tmi);
}
else if(temp>=tmx)
{
puts("Possible");
printf("%.4f\n",temp);
}
else
{
puts("Impossible");
}
return 0;
}

京公网安备 11010502036488号