提交时间:2022-04-10 15:54:01
运行 ID: 48190
#include <bits/stdc++.h> using namespace std; const int MXN = 100; struct node { int Min,Max,lson,rson; } t[4 * MXN + 1]; int a[MXN + 10],n; int main() { //freopen("game.in","r",stdin); //freopen("game.out","w",stdout); scanf("%d", &n); for(int i=1; i<=n; i++) scanf("%d", &a[i]); for(; n>1;) { int rec1,rec2,now1=0x7fffff,now2=0; for(int i=1; i<=n-1; i++)//Alice { int sum=max(a[i],a[i+1]); if(now1>sum) { now1=sum; rec1=i; } } if(a[rec1]<a[rec1+1]) rec1++; for(int i=rec1; i<=n-1; i++) a[i]=a[i+1]; n--; if(n==1) break; for(int i=1; i<=n-1; i++) { int sum=min(a[i],a[i+1]); if(now2<sum) { now2=sum; rec2=i; } } if(a[rec2]>a[rec2+1]) rec2++; for(int i=rec2; i<=n-1; i++) a[i]=a[i+1]; n--; if(n==1) break; } printf("%d\n", a[n]); return 0; }