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

wrong answer

Posted by HoShay at 2010-06-24 00:07:49 on Problem 2376
what the wrong with this code ? :

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int n,t;
vector <pair<int,int> > cow;

int main(){
    cin >>n >>t;
    for (int i=0;i<n;i++){
        int a,b;
        cin >>a >>b;
        cow.push_back(make_pair(a,b));
    }
    sort (cow.begin(),cow.end());
    int e=1,mx=-1,c=0,p=0;
    while (e<=t && p<cow.size()){
        while (cow[p].first<=e){
            mx=max(mx,cow[p].second);
            p++;
        }
        if (mx<e){
            cout <<-1<<endl;
            return 0;
        }
        c++;
        e=mx+1;
    }
    if (e==t+1)
        cout <<c<<endl;
    else
        cout <<-1<<endl;
    return 0;
}

it's better to give me e good test case and don't say my bug! tnx ! :)

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