zoukankan      html  css  js  c++  java
  • POJ 2379 ACM Rank Table (排序)

    挺恶心的一道题,陷阱不少,开始WA到死,过几天后一看才知道题目看漏了....说下需要注意的地方:

    1.每道题的时间是从比赛开始到AC+AC前提交的次数

    2.队伍AC后可能还提交,这时时间耗费是不算的

    3.数据输入的顺序是不一定的,也就是说两次AC,但是后面AC时间是最靠前的,这时后来提交的AC时间要忽略

    4.最后排序是AC->Time->id来排序的

    做题时要细心咯!

    #include <iostream>
    #include
    <cstdio>
    #include
    <memory.h>
    #include
    <algorithm>
    using namespace std;

    #define MAXN 1024

    struct Team{
    int num;
    int ac_time[31];
    int time[31][MAXN];
    int index[31];
    }team[MAXN];
    struct Node{
    int num;
    int ac;
    int time;
    }node[MAXN];
    bool cmp(const Node& a,const Node& b)
    {
    if(a.ac == b.ac)
    {
    if(a.time == b.time)
    return a.num<b.num;
    return a.time<b.time;
    }
    return a.ac>b.ac;
    }
    int main()
    {
    int i,j,tmp,num,prob,subtime,res,mmin,k,n;
    while(scanf("%d%d",&n,&k)!=EOF)
    {
    for(i = 1;i <= n; ++i)
    {
    team[i].num
    = i;
    memset(team[i].ac_time,
    -1,sizeof(team[i].ac_time));
    memset(team[i].index,
    0,sizeof(team[i].index));
    }
    for(i = 0;i < k; ++i)
    {
    scanf(
    "%d%d%d%d",&num,&prob,&subtime,&res);
    if(res)
    {
    if(team[num].ac_time[prob]==-1)
    team[num].ac_time[prob]
    = subtime;
    else
    team[num].ac_time[prob]
    =
    team[num].ac_time[prob]
    >subtime?
    subtime:team[num].ac_time[prob];
    }
    else
    {
    team[num].time[prob][team[num].index[prob]]
    = subtime;
    ++team[num].index[prob];
    }
    }
    for(i = 1;i <= n; ++i)
    {
    tmp
    = 0;
    node[i].num
    = i;
    node[i].ac
    = 0;
    node[i].time
    = 0;
    for(j = 1;j < 30; ++j)
    {
    if(team[i].ac_time[j] > 0)
    {
    ++node[i].ac;
    mmin
    = team[i].ac_time[j];
    for(k = 0;k < team[i].index[j];++k)
    {
    if(mmin>team[i].time[j][k])
    mmin
    =team[i].time[j][k];
    if(team[i].time[j][k] < team[i].ac_time[j])
    ++tmp;
    }
    node[i].time
    += (team[i].ac_time[j]);
    }
    }
    node[i].time
    += tmp*60*20;
    }
    sort(node
    +1,node+n+1,cmp);
    printf(
    "%d",node[1].num);
    for(i = 2;i <= n; ++i)
    printf(
    " %d",node[i].num);
    printf(
    "\n");
    }
    return 0;
    }

  • 相关阅读:
    SoapUI 使用笔记
    git 使用笔记(二)
    git 使用笔记(一)
    jquery 拓展
    hdu 1024 Max Sum Plus Plus (DP)
    hdu 2602 Bone Collector (01背包)
    hdu 1688 Sightseeing (最短路径)
    hdu 3191 How Many Paths Are There (次短路径数)
    hdu 2722 Here We Go(relians) Again (最短路径)
    hdu 1596 find the safest road (最短路径)
  • 原文地址:https://www.cnblogs.com/lvpengms/p/1690055.html
Copyright © 2011-2022 走看看