Gao The Sequence
计算出一个差值数组C[i], 一种操作, 找一个delate有C[i]-=delaie,找任意多个C[j]-=D[j] (j<i) 使sum(D[j])=delate, 问能否使C[i]全部赋0.
View Code
#include<cstdio> #define ll long long int main(){ int n; while(~scanf("%d",&n)){ ll a,b,c,s=0,m=0; while(n--){ scanf("%lld%lld",&a,&b); c=a-b;s+=c; if(c>m)m=c; } puts(s&1||s<m<<1?"NO":"YES"); } return 0; }