http://codeforces.com/contest/676
在allzysyz学弟和hqwhqwhq的邀请下,打了我的第三场CF。。。
毕竟在半夜。。所以本来想水到12点就去睡觉的。。。结果一下次过了三题,发现第四题是个bfs,就打到了12:30.。。。BC貌似是没有了,不知道后面还会不会有,最近就打CF为主吧。。
A题:
http://codeforces.com/problemset/problem/676/A
应该算是比较水吧。没有什么坑点。直接枚举最大值在最左最右侧和最小值在最左最右侧四种情况。
代码:
#include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <algorithm> #include <set> #include <map> #include <queue> #include <vector> #include <string> #define LL long long using namespace std; int main() { //freopen("test.in", "r", stdin); //freopen("test.out", "w", stdout); int n, t, indexone, indexn; while (scanf("%d", &n) != EOF) { for (int i = 0; i < n; ++i) { scanf("%d", &t); if (t == 1) indexone = i; if (t == n) indexn = i; } printf("%d\n", max(max(indexone, n-1-indexone), max(indexn, n-1-indexn))); } return 0; }