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

快速读入 110ms

Posted by hzoi_hexing at 2014-01-18 19:51:08 on Problem 2623
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
#define N 250001
int a[N];
int n;
void readln(int &x){
	x = 0;
	char ch;
	do{
		ch =  getchar();
		if (ch != EOF && ch != '\n') x = 10 * x + ch - 48;
	}while (ch != EOF && ch != '\n');
}

int main(){
	readln(n);
	for (int i = 1; i<=n; i++) readln(a[i]);
	sort(a + 1,a + n + 1);
	if (n & 1){
		printf("%d",a[(1 + n) >> 1]);
		puts(".0");
	}
	else{
		double t = a[n >> 1]/2.0 + a[(n >> 1) + 1]/2.0;
		printf("%.1f\n",t);
	}
	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