【习题 8-8 UVA - 1612】Guess
2024-09-03 11:03:15
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
double千万不要用==判断相等。。。
而且两个保留2位有效数字的数字x,y
判断它们相等应该这样。
int temp1 = round(x*100.0),temp2 = round(y*100.0);
temp1==temp2的话,才成立
不能直接*100
会出现精度误差。
然后就是把每个人的所有可能成绩都算出来(8种);
然后从大到小排序。
一开始每个人都得最高分。
set中以分数和id为关键字进行排序。
然后对于读入的第i个分数a[i]。
如果set的头元素不为a[i];
那么就让头元素的得分更低一点;
即从第i高的得分变成第i+1高的得分。
直到不能更低为止。(无解
【代码】
/*
1.Shoud it use long long ?
2.Have you ever test several sample(at least therr) yourself?
3.Can you promise that the solution is right? At least,the main ideal
4.use the puts("") or putchar() or printf and such things?
5.init the used array or any value?
6.use error MAX_VALUE?
7.use scanf instead of cin/cout?
8.whatch out the detail input require
*/
/*
一定在这里写完思路再敲代码!!!
*/
#include <bits/stdc++.h>
#define index fuck_index
using namespace std;
const int N = 2e4;
int n,index[N];
vector<double> v[N];
double vv[3];
struct abc{
int ind;
abc(int x):ind(x){}
friend bool operator < (abc a,abc b){
int temp1 = round(v[a.ind][index[a.ind]]*100.0);
int temp2 = round(v[b.ind][index[b.ind]]*100.0);
if (temp1!=temp2)
return temp1>temp2;
else
return a.ind<b.ind;
}
};
set <abc> myset;
bool ok(){
int pre;
for (int i = 1;i <= n;i++){
int x;cin >> x;
if (i==n){
cout <<fixed<<setprecision(2)<<v[x][index[x]] << endl;
return true;
}
while ( (*myset.begin()).ind!=x){
int temp = (*myset.begin()).ind;
myset.erase(myset.begin());
if (index[temp]==((int)v[temp].size()-1)) {
for (int j = i+1;j <= n;j++) cin >> x;
return false;
}
index[temp]++;
myset.insert(abc(temp));
}
myset.erase(myset.begin());
}
return true;
}
int main(){
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "r", stdin);
#endif
ios::sync_with_stdio(0),cin.tie(0);
int kase = 0;
while (cin>>n && n){
myset.clear();
for (int i = 1;i <= n;i++){
v[i].clear();
for (int j = 0;j < 3;j++) cin >> vv[j];
for (int j = 0;j < 3;j++) v[i].push_back(vv[j]);
for (int j = 0;j < 3;j++)
for (int k = j+1;k < 3;k++)
v[i].push_back(vv[j]+vv[k]);
v[i].push_back(vv[0]+vv[1]+vv[2]);
v[i].push_back(0);
sort(v[i].begin(),v[i].end());
reverse(v[i].begin(),v[i].end());
index[i] = 0;
}
for (int i = 1;i <= n;i++) myset.insert(abc(i));
cout<<"Case "<<++kase<<": ";
if (!ok()) cout <<"No solution"<<endl;
}
return 0;
}
最新文章
- EL表达式
- statcounter统计的浏览器市场占有率
- 【转】IOS高级教程1:处理1000张图片的内存优化
- LVS包转发模型和调度算法(转)
- js跳转页面方法整理
- 添加favicon.ico网站文件
- structDemo1
- css考核点整理(九)-有几种文字替换方式,之间的优缺点
- Request对象 --web浏览器向web服务端的请求
- [leetcode] Reverse Linked List 分类: leetcode 算法 2015-07-09 18:44 2人阅读 评论(0) 收藏
- Qt容器类(总结)(新发现的QQueue和QStack,注意全都是泛型)
- [转]简述负载均衡和CDN技术
- F - 娜娜梦游仙境系列——多民族王国
- ajax(省,市,县)三级联动
- python 排序之sort
- 【BZOJ2820】YY的GCD
- .NET MVC 学习笔记(二)— Bootstrap框架
- JAVA字符串怎么转换成整数
- 植物 miRNA 研究
- Oracle 统计量NO_INVALIDATE参数配置(上)