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 vince4053040 at 2010-01-31 19:46:50 on Problem 2104
#include<iostream>
#include<string>
#include<stdlib.h>
using namespace std;

#define MAX 100002

int cmp ( const void *a , const void *b ) 
{ 
	return *(int *)a - *(int *)b; 
}

int main()
{
	int N, m, p, q;
	cin >> N >> m;
	int x = 1, number, i;
	int a[MAX] = {0};
	char b[MAX] = {'0'};
	char cpy[MAX];
	while(N --)
		cin >> b[x ++];
	strcpy(cpy,b);
	while(m --) {
		for(i = 1; b[i] != '0'; i ++ )
			a[i] = b[i] - '0';
		scanf("%d%d%d", &p, &q, &number);
		qsort(a + p, q - p + 1, sizeof(int), cmp);   
		printf("%d\n", a[p + number - 1]);                //接下来应该返回 回到为排序时
		strcpy(b,cpy);
	}
	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