| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么过得这么险。。只有一个循环啊????Source
Problem Id:1852 User Id:qywyh_scut
Memory:504K Time:983MS
Language:C++ Result:Accepted
Source
#include <iostream>
#include <algorithm>
using namespace std;
const int MAXN = 1000000;
int ants[MAXN];
int main()
{
int caseTime;
int antsN, poleL;
int i;
int min, max, tmp1, tmp2;
cin >> caseTime;
while (caseTime-- != 0)
{
scanf("%d%d", &poleL, &antsN);
max = -1; min = -1;
for (i=0; i<antsN; i++)
{
cin >> ants[i];
tmp1 = ants[i] > poleL-ants[i] ? ants[i] : poleL-ants[i];
tmp2 = ants[i] < poleL-ants[i] ? ants[i] : poleL-ants[i];
max = max > tmp1 ? max : tmp1;
min = min > tmp2 ? min : tmp2;
}
cout << min << ' ' << max << endl;
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator