YTU 2902: H-Sum 3s
2902: H-Sum 3s
时间限制: 1 Sec 内存限制: 128 MB
提交: 139 解决: 28
题目描述
输入
Input consists of multiple test cases. For each case, the first line of input contains an integer n, the next line follows n integers. (n>=1 && n<=10^5 |ai|<=10^4)
输出
样例输入
51 2 3 4 553 4 -2 -3 1
样例输出
NOYES
im0qianqian_站在回忆的河边看着摇晃的渡船终年无声地摆渡,它们就这样安静地画下黄昏画下清晨......
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int N;
while (cin>>N)
{
int i,k=0,a[100000],s[100000];
cin>>a[0];
s[0]=a[0];
if (a[0]==0)
k=1;
for (i=1; i<N; i++)
{
cin>>a[i];
s[i]=s[i-1]+a[i];
if (a[i]==0||s[i]==0)
k=1;
}
if (k==0)
{
sort(s,s+N);
for (i=0; i<N-1; i++)
if (s[i]==s[i+1])
{
k=1;
break;
}
}
if (k==1)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl; }
return 0;
}
YTU 2902: H-Sum 3s的更多相关文章
- YTU 2905: The Sum of 1...N
2905: The Sum of 1...N 时间限制: 1 Sec 内存限制: 128 MB 提交: 281 解决: 51 题目描述 Given an integer n,your task i ...
- URAL 1146 Maximum Sum 最大子矩阵和
题目:click here #include <bits/stdc++.h> using namespace std; typedef unsigned long long ll; con ...
- Uva10290 - {Sum+=i++} to Reach N
Problem H {sum+=i++} to Reach N Input: standard input Output: standard output Memory Limit: 32 MB A ...
- [leetcode-560-Subarray Sum Equals K]
Given an array of integers and an integer k, you need to find the total number of continuous subarra ...
- 给定n个数字,问能否使这些数字相加得到h【折半查找/DFS】
A Math game Time Limit: 2000/1000MS (Java/Others) Memory Limit: 256000/128000KB (Java/Others) Submit ...
- PAT 1049. 数列的片段和(20)
给定一个正数数列,我们可以从中截取任意的连续的几个数,称为片段.例如,给定数列{0.1, 0.2, 0.3, 0.4},我们有(0.1) (0.1, 0.2) (0.1, 0.2, 0.3) (0.1 ...
- Mysql 常用 SQL 语句集锦
Mysql 常用 SQL 语句集锦 基础篇 //查询时间,友好提示 $sql = "select date_format(create_time, '%Y-%m-%d') as day fr ...
- POJ 3233Matrix Power Series
妈妈呀....这简直是目前死得最惨的一次. 贴题目: http://poj.org/problem?id=3233 Matrix Power Series Time Limit: 3000MS Mem ...
- Gym 100703I---Endeavor for perfection(尺取)
题目链接 http://codeforces.com/problemset/gymProblem/100703/I Description standard input/outputStatement ...
随机推荐
- ArrayList集合的遍历
ArrayLIstDemo3.java import java.util.ArrayList; public class ArrayListDemo3 { public static void mai ...
- java数据结构简单点
java常用的数据结构一 集合框架主要就是Collection和Map: 1.Collection包含了List和Set两大分支. (1)List是一个有序的集合,每一个元素都有它的索引.第一个元素的 ...
- CSU 1290 DP解决数学期望问题
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1290 题目大意: 给定k个数,每次可以生成0-N-1中的任何一个数,k个数中出现不同的整 ...
- 洛谷P1757 通天之分组背包
题目背景 直达通天路·小A历险记第二篇 题目描述 自01背包问世之后,小A对此深感兴趣.一天,小A去远游,却发现他的背包不同于01背包,他的物品大致可分为k组,每组中的物品相互冲突,现在,他想知道最大 ...
- 【BFS+优先级队列】Rescue
https://www.bnuoj.com/v3/contest_show.php?cid=9154#problem/I [题意] 给定一个n*m的迷宫,A的多个小伙伴R要去营救A,问需要时间最少的小 ...
- 【数学】codeforces C. Maximal GCD
http://codeforces.com/contest/803/problem/C [题意] 给定两个数n,k(1 ≤ n, k ≤ 10^10) 要你输出k个数,满足以下条件: ①这k个数之和等 ...
- sencha architect开发sencha touch应用注意事项
以下说明文字针对sencha architect v2.2.2 一.无限期试用 1. 下载地址: http://www.sencha.com/products/architect/download/ ...
- Codeforces Round #296 (Div. 2) C. Glass Carving [ set+multiset ]
传送门 C. Glass Carving time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- dsu on tree:关于一类无修改询问子树可合并问题
dsu on tree:关于一类无修改询问子树可合并问题 开始学长讲课的时候听懂了但是后来忘掉了....最近又重新学了一遍 所谓\(dsu\ on\ tree\)就是处理本文标题:无修改询问子树可合并 ...
- HDTVI,HDCVI
HDTVI是海康的同轴高清标准,HDCVI是大华的同轴高清标准,二者互相不兼容.