玲珑Round #7-1071 - Boring Game
来源:互联网 发布:moga算法 编辑:程序博客网 时间:2024/06/11 15:53
Time Limit:1s Memory Limit:1024MByte
Submissions:612Solved:200
In a mysterious cave, PigVan ( Mr.Van's pet ) has lived for thousands years. PigVan absorbed the power of nature, and it may pretend a human in speaking, walking and so on.
One day, he bought some valuable stone, and divided them into n piles of stone where the ith pile (1≤i≤n) contains valuesai .
After PigVan put them in a line, he wants to play a game.
In the boring game, he can do this operation:
Choose a stone pile ai (i>1)and its two adjacent piles ai-1, ai+1, turn(ai-1, ai, ai+1) to(ai-1 + ai, -ai, ai + ai+1).
PigVan wonders whether he can get (b1, b2, b3, …, bn) after several operations.
Note:
If you choose the last pile an, the operation will be( an-1 + an, -an ) .
For each test case:
In the first line, there are only one integer nn(n≤105), indicating the number of food piles.
The second line is nn integers indicate sequence aa ( | ai | ≤ 106).
The third line is nn integers indicate sequence bb ( | bi | ≤ 106).
#include<cstdio>#include<algorithm>using namespace std;int main(){int a[100000],b[100000];int t,n;scanf("%d",&t);while(t--){scanf("%d",&n);a[0]=0;b[0]=0;for(int i=1;i<=n;i++){scanf("%d",&a[i]);a[i]+=a[i-1];}for(int i=1;i<=n;i++){scanf("%d",&b[i]);b[i]+=b[i-1];}sort(a+1,a+n+1);sort(b+1,b+n+1);int faut=1;for(int i=1;i<=n;i++){if(a[i]!=b[i])faut=0;}if(faut==1) printf("Yes\n");else printf("No\n");}return 0;}
- 玲珑Round #7-1071 - Boring Game
- 玲珑oj 1071 - Boring Game
- 玲珑学院OJ 1071 Boring Game【思维】
- 玲珑杯-Boring Game
- 【玲珑杯R7 A】Boring Game
- LonLife 1071 - Boring Game
- Boring Game
- 玲珑学院oj Round#7
- “玲珑杯”ACM比赛 Round #7
- “玲珑杯”ACM比赛 Round #7
- HDU 2419 Boring Game
- hdu 4592 Boring Game
- hdu 2419 Boring Game
- A Boring Game
- Codeforces Round #421 (Div. 2) C. Mister B and Boring Game
- “玲珑杯”Round #11
- 玲珑杯 Round #20
- zoj 3352 Boring Board Game
- Hololens——Assetbundle处理
- 线性表顺序存储设计与实现_框架搭建
- Hbase之批量数据写入
- loadrunner11 报Abnormal termination, caused by mdrv process termination的解决方法.
- FrameLayout
- 玲珑Round #7-1071 - Boring Game
- pat-bl-1028
- Multi-view Convolutional Neural Networks for 3D Shape Recognition
- Android音视频学习第1章:使用ffmpeg进行视频解码
- 解释器模式--Excel公式嵌套
- 性能测试2-性能测试流程
- Rxjava2.0和Retrofit简单封装使用
- hermite曲线
- jmap -histo ,jmap dumpfile, jstack