HDU 4524
简单题,先从右边消起,注意结束时a[1]==0才能是yes
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int N=1000050; int a[N],n; int main(){ int T; scanf("%d",&T); while(T--){ scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); bool flag=true; for(int i=n-1;i>0;i--){ if(a[i]<a[i+1]){ flag=false; break; } a[i]-=a[i+1]; a[i+1]=0; if(a[i]==0) i--; } if(flag&&a[1]==0) puts("yeah~ I escaped ^_^"); else puts("I will never go out T_T"); } return 0; }