• 【习题 8-8 UVA


    【链接】 我是链接,点我呀:)
    【题意】

    在这里输入题意

    【题解】

    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;
    }
    
    
  • 相关阅读:
    不会写研发部门OKR?来这里看看吧
    HR 必须了解的绩效考核
    成功的OKR复盘会需要注意什么
    effective解读-第一条 静态工厂创建对象代替构造器
    灾难恢复:邮箱数据库操作总结:整理 查询邮箱数据库大小和空白数据大小(重要文档)
    Exchange传输队列queue数据库mail.que文件越来越大(重要文档)
    Exchange2016邮件流(重要文档)
    Exchange2016服务器使用到的9个端口
    VMware EXSI 启用vMotion
    Exchange2016DAG的配置
  • 原文地址:https://www.cnblogs.com/AWCXV/p/8254026.html
Copyright © 2020-2023  润新知