Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么re。。。

Posted by kofrong at 2009-07-29 14:00:56 on Problem 1456
#include<iostream>
#include<algorithm>

using namespace std;

struct node
{
    int deadlie;
    int profie;
}pro[20000];

bool cmp(node a,node b)
{
    return a.deadlie<b.deadlie;
}
bool cmp2(node a,node b)
{
    return (a.deadlie==b.deadlie&&a.profie<b.profie);
}
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        for(int i=0;i!=n;i++)
        {
            scanf("%d%d",&pro[i].profie,&pro[i].deadlie);
        }
        sort(pro,pro+n,cmp);
        sort(pro,pro+n,cmp2);
        /*for(int i=0;i!=n;i++)
        {
            printf("%d %d ",pro[i].profie,pro[i].deadlie);
        }*/
        int max=pro[n-1].profie;
        for(int i=0;i!=n-1;i++)
        {
            if(pro[i].deadlie<pro[i+1].deadlie)
            {
                max+=pro[i].profie;
            }
        }
        printf("%d\n",max);
    }
    return 0;
    
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator