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

冒泡TLE,qsort 219MS,测试数据看来够大···(附代码)

Posted by songzhenqi at 2010-10-22 13:06:29 on Problem 2371
#include <iostream>
using namespace std;

int base[100005];
char str[5];
int n,k;

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

int main()
{   
//	freopen("in.txt","r",stdin);
	int i;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>base[i];
	qsort(base,n,sizeof(int),compare);
	cin>>str;
	cin>>k;
	int test;
	while(k--)
	{   
		cin>>test;
		cout<<base[test-1]<<endl;  
	}
	return 0;
}

除了1000,估计这是我写的最短的一次··

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