zoukankan      html  css  js  c++  java
  • 【codeforces 807D】Dynamic Problem Scoring

    【题目链接】:http://codeforces.com/contest/807/problem/D

    【题意】

    给出n个人的比赛信息;
    5道题
    每道题,或是没被解决->用-1表示;
    或者给出解题的所用的时间;
    (每道题的分数与解决率有关,越高,分越低);
    然后有个人想利用这个特点,注册很多个账号;
    试图改变每道题的解决率,以期让自己的分数大于某个人;
    如果这个人没有解决某道题的话;
    那些新加入的人也不能解决那道题.
    问最少需要注册多少个账号才能让你的分数大于某个人;

    【题解】

    顺序枚举加入了多少个人->k;
    对于自己做得快的题,让这道题的解决率变低,让这题更有价值,即这k个人都没做对;
    对于自己做得慢的题,让这道题的解决率变高,让这题价值变得低一点,即这k个人都做对了这题;
    当然,对于你自己都没做对的题,你只能让他们都做不对这题啦

    【Number Of WA

    1

    【完整代码】

    #include <bits/stdc++.h>
    using namespace std;
    #define lson l,m,rt<<1
    #define rson m+1,r,rt<<1|1
    #define LL long long
    #define rep1(i,a,b) for (int i = a;i <= b;i++)
    #define rep2(i,a,b) for (int i = a;i >= b;i--)
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define ms(x,y) memset(x,y,sizeof x)
    
    typedef pair<int,int> pii;
    typedef pair<LL,LL> pll;
    
    const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
    const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
    const double pi = acos(-1.0);
    const int N = 120+20;
    
    int n,solves[6],a[N][6],tsolves[6];
    
    int cal(int time,int ac,int tot)
    {
        if (time==-1) return 0;
        if (2*ac>tot) return 2*(250-time);
        if (4*ac>tot) return 4*(250-time);
        if (8*ac>tot) return 6*(250-time);
        if (16*ac>tot) return 8*(250-time);
        if (32*ac>tot) return 10*(250-time);
        return 12*(250-time);
    }
    
    bool check(int k)//k是枚举的添加的cheater参赛选手个数
    {
        rep1(i,1,5) tsolves[i] = solves[i];
        rep1(i,1,5)
        {
            if (a[1][i]!=-1)//需要先解决这个问题,新注册的账号才能提交正确的
            {
                if (a[2][i]==-1)
                {
                    //keep the ratio
                }
                else
                    if (a[1][i]>a[2][i])//如果用的时间比较长,让这个题的AC率
                    //提高
                    {
                        tsolves[i]+=k;
                    }
            }
        }
        int l = 0,r = 0;
        rep1(i,1,5)
        {
            l+=cal(a[1][i],tsolves[i],n+k);
            r+=cal(a[2][i],tsolves[i],n+k);
        }
        return l>r;
    }
    
    int main()
    {
        //freopen("D:\\rush.txt","r",stdin);
        ios::sync_with_stdio(false),cin.tie(0);//scanf,puts,printf not use
        cin >> n;
        rep1(i,1,n)
        {
            rep1(j,1,5)
            {
                cin >> a[i][j];
                if (a[i][j]!=-1)
                    solves[j]++;
            }
        }
        rep1(i,0,n*33)
        {
            if (check(i))
            {
                cout <<i <<endl;
                return 0;
            }
        }
        cout <<-1<<endl;
        return 0;
    }
    
  • 相关阅读:
    英语46级CET外语大学词汇
    TOEFL词汇笔记英语托福英语
    19道常见的JS面试算法题
    Vue.js---指令与事件、语法糖
    Qt--多线程间的互斥
    const关键字总结
    Numpy和Pandas的使用入门
    python爬虫爬取天气数据并图形化显示
    JCEF-鼠标右键菜单
    JCEF-tab形式展示浏览器
  • 原文地址:https://www.cnblogs.com/AWCXV/p/7626332.html
Copyright © 2011-2022 走看看