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 KatrineYang at 2016-07-09 08:10:39 on Problem 1089
//============================================================================
// Name        : main1089.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;


int dao[1000001] = {0};

int main() {
	int N;
	cin >> N;
	//intv l[50000];

	int min = 1000001, max = 0;
	for(int i = 0; i < N; i++){
		int temps, tempe;
		cin >> temps >> tempe;
		if(dao[temps] < tempe) dao[temps] = tempe;
		if(temps < min) min = temps;
		if(tempe > max) max = tempe;

	}
	int start = min, end = dao[min];
	for(int i = min+1; i <= max; i++){
		if(dao[i] == 0) continue;
		if(i > end){
			cout << start << " " << end << endl;
			start = i;
			end = dao[i];
		}
		else{
			if(end < dao[i]) end = dao[i];
		}
		/*
		if(end == max){
			cout << start << " " << end << endl;
			break;
		}
		*/
	}
	cout << start << " " << end << endl;
	//quickSort(l, 0, N-1);

	//cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
	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