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:只用125ms

Posted by xiaodaiyang at 2022-12-20 00:02:29 on Problem 1089
In Reply To:只用125ms Posted by:xiaodaiyang at 2022-12-20 00:01:43
#include<iostream>
#include<stdio.h>
using namespace std;
int vis[1000005];
int main()
{
	int n;
	cin >> n;
	while (n--){
		int a, b;
		scanf("%d%d", &a, &b);
		if (vis[a] < b)vis[a] = b;
	}
	for (int i = 1; i < 1000005; i++){
		if (vis[i]) {
			printf("%d ", i);
			int k = vis[i];
			for (int j = i + 1; j <= k; j++)
				if (vis[j] > k)k = vis[j];
			printf("%d\n", k);
			i = k;
		}
	}
	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