ZOJ 3672 Gao The Sequence
来源:互联网 发布:centos 6 docker 1.12 编辑:程序博客网 时间:2024/05/02 06:09
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3672
You are given a sequence of integers, A1,A2,...,An. And you are allowed a manipulation on the sequence to transform the origin sequence into another sequence B1,B2,...,Bn(Maybe the two sequences are same ). The manipulation is specified as the following three steps:
1.Select an integer Ai and choose an arbitrary positive integer delta as you like.
2.Select some integers Aj satisfying j < i, let's suppose the selected integers are Ak1,Ak2,...,Akt , then subtract an arbitrary positive integer Di from Aki (1 ≤ i ≤ t) as long as sum(Di) = delta.
3.Subtract delta from Ai.
The manipulation can be performed any times. Can you find a way to transform A1,A2,...,An to B1,B2,...,Bn ?
Input
The input consist of multiple cases. Cases are about 100 or so. For each case, the first line contains an integer N(1 ≤ N ≤ 10000) indicating the number of the sequence. Then followed by N lines, ith line contains two integers Ai and Bi (0 ≤ Bi ≤ Ai ≤ 4294967296).
Output
Output a single line per case. Print "YES" if there is a certain way to transform Sequence A into Sequence B. Print "NO" if not.
Sample Input
33 24 25 232 07 13 1
Sample Output
YESNO
Author: LI, Wenchao
Contest: ZOJ Monthly, November 2012
一道简单题。
#include<iostream>#include<cstring>#include<cstdio>#include<vector>#include<string>#include<sstream>#include<algorithm>#include<cmath>#include<vector>#include<set>#include<cstdlib>#include<map>using namespace std;#define CLR(A) memset(A,0,sizeof(A))int main(){ int n; while(~scanf("%d",&n)){ long long sum=0,a,b; long long maxv=0; while(n--){ scanf("%lld%lld",&a,&b); sum+=(a-b); maxv=max(maxv,a-b); } if(sum&1||2*maxv>sum){ cout<<"NO"<<endl; } else{ cout<<"YES"<<endl; } } return 0;}
- zoj 3672 Gao The Sequence
- zoj - 3672 - Gao The Sequence
- ZOJ 3672 Gao The Sequence
- ZOJ3672:Gao The Sequence
- ZOJ 3647 Gao the Grid
- ZOJ 3647 Gao the Grid
- zoj 3647 Gao the Grid
- ZOJ-3647 Gao the Grid
- ZOJ 3647 Gao the Grid
- ZOJ 3535 Gao the String II
- ZOJ 3648 Gao the Grid II
- Zoj 3647 Gao the Grid (数论?)
- zoj 3535 Gao the String II(ac自动机+dp)
- zoj 3533 Gao the String I(伸展树+字符串hash)
- zoj 3535 Gao the String II(AC自动机+DP)
- Zoj 3535 Gao the String II (AC自动机+dp)
- ZOJ 3647 Gao the Grid(居然是暴力)
- zoj 3535 Gao the String II (ac自动机+dp)
- 日媒称中国民间没资格向日追索国宝 只为抹黑日
- 数据库系统原理之第一章数据系统基本概念总结
- Codeforces Round #258 (Div. 2)E(组合数+容斥原理)
- 长沙2014秋季中学收费标准出炉 最高每期1419元
- 最小生成树与最短路的区别
- ZOJ 3672 Gao The Sequence
- hdu 2492 Ping pong (树状数组)
- 注册表中控制键、段名、键名
- 第六章数据结构基础之树部分
- 不要让未来的你,讨厌现在的自己
- (弃疗搁置)poj 1821 Fence
- C6能比C8快多少(Altera的FPGA速度等级)
- 黑马程序员—(iOS开发)C语言概述---(一)
- 关于python的决策