题目链接:http://codeforces.com/contest/676/problem/A
题意:给一个1~n的序列,可以交换一次任意两个数,求交换后1和n的最远的距离
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define lowbit(x) (x&(-x))
typedef long long LL;
const int maxn = 10005;
const int inf=(1<<28)-1;
int A[maxn];
int main()
{
int n;
scanf("%d",&n);
int pos1,pos2;
for(int i=1;i<=n;++i)
{
int x;
scanf("%d",&x);
if(x==1) pos1=i;
if(x==n) pos2=i;
}
int ans=0;
ans=max(n-pos1,n-pos2);
ans=max(pos1-1,ans);
ans=max(pos2-1,ans);
printf("%d\n",ans);
return 0;
}