首页 > 代码库 > AC日记——Dynamic Problem Scoring codeforces 807d

AC日记——Dynamic Problem Scoring codeforces 807d

Dynamic Problem Scoring

 

思路:

  水题;

 

代码:

#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;#define maxn 130int n,ai[maxn][6],ac[6],cnt,all,last1,last2;double map[3][6];inline void in(int &now){    int if_z=1;now=0;    char Cget=getchar();    while(Cget>9||Cget<0)    {        if(Cget==-) if_z=-1;        Cget=getchar();    }    while(Cget>=0&&Cget<=9)    {        now=now*10+Cget-0;        Cget=getchar();    }    now*=if_z;}int point(int a,int s,int t){    if(t==-1) return 0;    int res=0;    double p=(double)a/(double)s;    if(p>0.5&&p<=1) res+=500-2*t;    else if(p>0.25&&p<=0.5) res+=1000-4*t;    else if(p>0.125&&p<=0.25) res+=1500-t*6;    else if(p>0.0625&&p<=0.125) res+=2000-t*8;    else if(p>0.03125&&p<=0.0625) res+=2500-t*10;    else if(p>0&&p<=0.03125) res+=3000-t*12;    return res;}int main(){    in(n);    for(int i=1;i<=n;i++)    {        for(int j=1;j<=5;j++)        {            in(ai[i][j]);            if(ai[i][j]!=-1) ac[j]++;        }    }    for(int i=1;i<=5;i++)    {        last1+=point(ac[i],n,ai[1][i]);        last2+=point(ac[i],n,ai[2][i]);    }    cnt=n;    if(last1>last2)    {        printf("0");        return 0;    }    for(int j=1;j<=10000;j++)    {        cnt++;        int sco1=0,sco2=0;        bool if_[6];        for(int i=1;i<=5;i++)        {            if(ai[1][i]==-1&&ai[2][i]==-1) continue;            int k1=point(ac[i]+1,cnt,ai[1][i]);            int k2=point(ac[i],cnt,ai[1][i]);            int g1=point(ac[i]+1,cnt,ai[2][i]);            int g2=point(ac[i],cnt,ai[2][i]);            if(ai[1][i]==-1)            {                sco2+=g2;                continue;            }            if(ai[2][i]==-1)            {                sco1+=k2;                continue;            }            if(ai[1][i]<ai[2][i])            {                sco1+=k2;                sco2+=g2;            }            else            {                ac[i]++;                sco1+=k1;                sco2+=g1;            }        }        last1=sco1,last2=sco2;        if(last1>last2)        {            cout<<cnt-n;            return 0;        }    }    cout<<-1;    return 0;}

 

AC日记——Dynamic Problem Scoring codeforces 807d