# zoj 3672 思维题

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4915

1、segma(a[i]-b[i])必须是偶数，，因为其实每次操作都是相当于从segma(a[i]-b[i])里面减去2*delta

2、a[i]>=b[i] 题目说的很清楚，只能减去，所以这点必须满足

3、max(a[i]-b[i]) * 2  <= segma(a[i]-b[i])  否则的话，最大的肯定消不掉

```#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <queue>
using namespace std;

#define ls(rt) rt*2
#define rs(rt) rt*2+1
#define ll long long
#define ull unsigned long long
#define rep(i,s,e) for(int i=s;i<e;i++)
#define repe(i,s,e) for(int i=s;i<=e;i++)
#define CL(a,b) memset(a,b,sizeof(a))
#define IN(s) freopen(s,"r",stdin)
#define OUT(s) freopen(s,"w",stdout)
const ll ll_INF = ((ull)(-1))>>1;
const double EPS = 1e-8;
const int INF = 100000000;

const int MAXN = 10000+100;
ll a[MAXN],b[MAXN];
ll vis[MAXN];
int n;

int main()
{
while(~scanf("%d",&n))
{
CL(vis,0);
int flag=1;
ll mmax=0,ret=0;
for(int i=0;i<n;i++)
{
scanf("%lld%lld",&a[i],&b[i]);
if(a[i]<b[i])flag=0;
if(a[i]>=b[i])vis[i]=a[i]-b[i];
mmax=max(vis[i],mmax);
ret+=vis[i];
}
if(flag==0 || 2*mmax >ret || ret%2)
printf("NO\n");
else
printf("YES\n");

}
return 0;
}
```

zoj 3672 思维题

(0)
(0)

0条