2017美团编程大赛初赛A-C.倒水
2017-06-19 20:51
716 查看
记录一个菜逼的成长。。
分为几种种情况讨论:
1.T比所有的水杯的温度都高,就把所有的水倒完。
先按最高温度倒,然后剩余的按水杯的体积比例倒
2.T比所有的水杯的温度都低,就按最低的水杯温度倒
3.在中间则是Impossible
4.最高温度等于最低温度并且T等于最高温度的话,就是T
水不够的都是Impossible
(数据有点弱。自己ac的代码自己找出数据卡掉了
分为几种种情况讨论:
1.T比所有的水杯的温度都高,就把所有的水倒完。
先按最高温度倒,然后剩余的按水杯的体积比例倒
2.T比所有的水杯的温度都低,就按最低的水杯温度倒
3.在中间则是Impossible
4.最高温度等于最低温度并且T等于最高温度的话,就是T
水不够的都是Impossible
(数据有点弱。自己ac的代码自己找出数据卡掉了
#include <stdio.h> #include <math.h> #include <assert.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; #define ALL(v) (v).begin(),(v).end() #define cl(a,b) memset(a,b,sizeof(a)) #define clr clear() #define pb push_back #define mp make_pair #define fi first #define se second typedef pair<int,int> PII; typedef pair<double,double> PDD; const int maxn = 100000 + 10; PDD a[maxn]; int main() { int n; while(~scanf("%d",&n)){ double T,C;scanf("%lf%lf",&T,&C); double mxt = 0,mnt = 100000; double tot = 0; for( int i = 1; i <= n; i++ ){ scanf("%lf%lf",&a[i].fi,&a[i].se); mxt = max(mxt,a[i].fi); mnt = min(mnt,a[i].fi); tot += a[i].se; } if(mxt == mnt && T == mxt){ printf("Possible\n%.4f\n",T); continue; } if(mxt < T){ for( int i = 1; i <= n; i++ ){ if(mxt == T)continue; double tmp = (a[i].fi - mxt) * a[i].se / (mxt - T); C -= tmp; a[i].fi = mxt; a[i].se += 4000 tmp; tot += tmp; if(C < 0){ puts("Impossible"); return 0; } } printf("Possible\n%.4f\n",(a[1].se*C/tot*T + a[1].se*a[1].fi) / (a[1].se/tot*C + a[1].se)); } else if(mnt > T){ for( int i = 1; i <= n; i++ ){ if(mnt == T)continue; C -= (double)(a[i].fi - mnt) * a[i].se / (mnt - T); if(C < 0){ puts("Impossible"); return 0; } } printf("Possible\n%.4f\n",(double)mnt); } else { puts("Impossible"); } } return 0; }
相关文章推荐
- 2017美团编程大赛初赛B-E.子串(进制转换+KMP)
- CodeM美团点评编程大赛初赛A轮 C.倒水【二分+分类讨论】
- 用python实现csdn第四届在线编程大赛·线上初赛:带通配符的数
- 第二届“顶嵌杯”全国嵌入式系统C语言编程大赛初赛试题分析及题解
- CSDN第四届在线编程大赛2014初赛:带通配符的数
- CodeM美团点评编程大赛初赛A轮 B.合并回文子串【区间Dp】
- CodeM美团点评编程大赛 初赛B轮 A 黑白树 贪心 E 子串 暴力
- 英雄会第四届在线编程大赛·线上初赛:带通配符的数
- 英雄会第四届在线编程大赛·线上初赛:带通配符的数
- 2014第六届华为创新杯编程大赛初赛解题报告
- 【结果发布】第六届SeedCoder编程大赛初赛结果发布
- CodeM美团点评编程大赛初赛A轮
- CodeM美团点评编程大赛初赛B轮题解
- 第四届在线编程大赛·线上初赛:带通配符的数-我的解题方法
- 2013华为第五届编程大赛 成都初赛题目和解答
- 2017美团点评编程大赛资格赛 --- 音乐研究
- CodeM美团点评编程大赛A轮 C.倒水
- CodeM美团点评编程大赛初赛B轮
- 【Java】 英雄会第四届在线编程大赛·线上初赛:带通配符的数 Java实现
- 英雄会第四届在线编程大赛·线上初赛:带通配符的数