守恒法的问题,表示,刚刚看了一点点

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
int T, n;
bool flag;
int num[10005];
int ans[10005];
int sux[10005];
int sum[10005];
cin>>T;
while(T--)
{
memset(num, 0, sizeof(num));
memset(sum, 0, sizeof(sum));
memset(ans, 0, sizeof(ans));
memset(sux, 0, sizeof(sux));
flag = true;
cin>>n;
for(int i = 1; i <= n; i++)
{
cin>>num[i];
sum[i] = sum[i-1] + num[i];
}
for(int i = 1; i <= n; i++)
{
cin>>ans[i];
sux[i] = sux[i-1] + ans[i];
}
sort(sum+1, sum+1+n);
sort(sux+1, sux+1+n);
for(int i = 1; i <= n; i++)
if(sum[i]!=sux[i]) flag = false;
if(flag) printf("Yes\n");
else printf("No\n");
}
return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

NYOJ-109 数列转换 AC 分类: NYOJ 2014-12-01 00:54 84人阅读 评论(0) 收藏的更多相关文章

  1. c++ 字符串流 sstream(常用于格式转换) 分类: C/C++ 2014-11-08 17:20 150人阅读 评论(0) 收藏

    使用stringstream对象简化类型转换 C++标准库中的<sstream>提供了比ANSI C的<stdio.h>更高级的一些功能,即单纯性.类型安全和可扩展性.在本文中 ...

  2. C/C++中const的用法 分类: C/C++ 2015-07-05 00:43 85人阅读 评论(0) 收藏

    const是C语言的关键字,经C++进行扩充,变得功能强大,用法复杂.const用于定义一个常变量(只读变量),当const与指针,引用,函数等结合起来使用时,情况会变得复杂的多.下面将从五个方面总结 ...

  3. 浅谈new operator、operator new和placement new 分类: C/C++ 2015-05-05 00:19 41人阅读 评论(0) 收藏

    浅谈new operator.operator new和placement new C++中使用new来产生一个存在于heap(堆)上对象时,实际上是调用了operator new函数和placeme ...

  4. Least Common Ancestors 分类: ACM TYPE 2014-10-19 11:24 84人阅读 评论(0) 收藏

    #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #i ...

  5. short-path problem (Spfa) 分类: ACM TYPE 2014-09-02 00:30 103人阅读 评论(0) 收藏

    #include <cstdio> #include <iostream> #include <cstring> #include <queue> #i ...

  6. Monthly Expense(二分) 分类: 二分查找 2015-06-06 00:31 10人阅读 评论(0) 收藏

    Description Farmer John is an astounding accounting wizard and has realized he might run out of mone ...

  7. iOS动画特效 分类: ios技术 2015-05-15 16:29 311人阅读 评论(0) 收藏

    关于图层的几个坐标系. 对于ios来说,坐标系的(0,0)点在左上角,就是越往下,Y值越大.越往右,X值越大. 一个图层的frame,它是position,bounds,anchorPoint和tra ...

  8. NYOJ-36 最长公共子序列 AC 分类: NYOJ 2014-01-03 20:54 155人阅读 评论(0) 收藏

    #include<stdio.h> #include<string.h> #define N 1010 #define max(x,y) x>y?x:y int dp() ...

  9. NYOJ-733 万圣节派对 AC 分类: NYOJ 2014-01-02 00:41 303人阅读 评论(0) 收藏

    #include <stdio.h> #include <math.h> int main() { int t, a, b, i, j, n; scanf("%d&q ...

随机推荐

  1. php 引入其他文件中的变量

    在php的开发过程中,如果所有的代码都写在同一个文件中的话,那么文件中的代码数量是否太多了,一来不便维护,二来对于编辑器也是个负担include("class0.php");在ph ...

  2. 解决 AUTH` failed: ERR Client sent AUTH, but no password is set [tcp://127.0.0.1:6379]

    页面报错: ConnectionException In AbstractConnection.php line 155 AUTH` failed: ERR Client sent AUTH, but ...

  3. element中的tree组件实现菜单分配

    返回的菜单数据 tree组件的使用 <el-tree ref="menuList" // :data="menuList" // 展示数据 :props= ...

  4. 使用Process子类创建进程

    #_author:来童星#date:2019/12/17# 使用Process子类创建进程from multiprocessing import Processimport timeimport os ...

  5. BOM的介绍

    BOM的概念 BOM(Browser Object Model) 是指浏览器对象模型,浏览器对象模型提供了独立于内容的.可以与浏览器窗口进行互动的对象结构.BOM由多个对象组成,其中代表浏览器窗口的W ...

  6. webstorm常见快捷方法与遇到的一些问题

    1.动态添加标签快捷写法 例子:生成10个文字按顺序编号的class为task-item的div 2.win10下webstorm的terminal无法输入? 打开一个 cmd.exe,标题栏 右键 ...

  7. java script 基本函数

    Math.random()    是令系统随机选取大于等于 0.0 且小于 1.0 的伪随机 double 值. 日期时间函数(需要用变量调用):var b = new Date();      // ...

  8. [HL] 7.5 集训总结

    对于某唤做赛区难度的题,我只能是内流满面..拿到题,A神题不可做,B,神题不可做,C,神题不可做...最后yy了一个A的算法...只得了20 TAT.C题骗分似乎有50 ..B题本来想骗分..然后/ ...

  9. CSS3:目录

    ylbtech-CSS3:目录 1.返回顶部 1. http://www.runoob.com/css3/css3-tutorial.html 2. 2.返回顶部   3.返回顶部   4.返回顶部 ...

  10. 分布式存储glusterfs

    什么是glusterfs? Glusterfs是一个开源分布式文件系统,具有强大的横向扩展能力,可支持数PB存储容量的数干客户端,通过网络互联成一个并行的网络文件系统.具有可扩展性.高性能.高可用性等 ...