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

貌似是最简单的贪心算法,机器时间的那个

Posted by guangmingge at 2013-07-07 20:50:49 on Problem 1083
太水了...贴个代码
#include<iostream>
#include<cstring>
using namespace std;
int corrid[210];
int main(){
        int T;
        cin>>T;
        while(T--){
            memset(corrid,0,sizeof(corrid));
            int n;
            cin>>n;
            while(n--){
                int a,b;
                cin>>a>>b;
                if(a>b){
                    int tmp = a;
                    a = b;
                    b = tmp;
                }

                if(a%2==1)
                        a++;
                a = a/2;
                if(b%2==1)
                        b++;
                b = b/2;
                while(a<=b){
                        corrid[a]++;
                        a++;
                }
            }
                int mx(0);
                for(int i=1;i<200;i++)
                        if(mx<corrid[i])
                                mx = corrid[i];
                cout<<mx*10<<endl;
        }
        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