Codeforces 890A - ACM ICPC 暴力
A. ACM ICPC
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to participate, the decision was to build exactly two teams.
After practice competition, participant number i got a score of ai. Team score is defined as sum of scores of its participants. High school management is interested if it's possible to build two teams with equal scores. Your task is to answer that question.
Input
The single line contains six integers a1, ..., a6 (0 ≤ ai ≤ 1000) — scores of the participants
Output
Print "YES" (quotes for clarity), if it is possible to build teams with equal score, and "NO" otherwise.
You can print each character either upper- or lowercase ("YeS" and "yes" are valid when the answer is "YES").
Examples
input
1 3 2 1 2 1
output
YES
input
1 1 1 1 1 99
output
NO
Note
In the first sample, first team can be composed of 1st, 2nd and 6th participant, second — of 3rd, 4th and 5th: team scores are 1 + 3 + 1 = 2 + 1 + 2 = 5.
In the second sample, score of participant number 6 is too high: his team score will be definitely greater.
思路:
问6个数能否被2人平分
代码:
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
int a[];
int sum=;
for(int i=;i<=;++i) {
cin>>a[i];
sum+=a[i];
}
if(sum%!=) {
cout<<"NO"<<endl;
return ;
}
int flag=;
for(int i=;i<=;++i) {
for(int j=i+;j<=;++j) {
for(int k=j+;k<=;++k) {
if((a[i]+a[j]+a[k])==(sum/)) {
flag=;
break;
}
}
}
}
if(flag) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return ;
}
Codeforces 890A - ACM ICPC 暴力的更多相关文章
- Codeforces Round #445 A. ACM ICPC【暴力】
A. ACM ICPC time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...
- ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 D. Delay Time
Problem D. Delay Time Input file: standard input Output file: standard output Time limit: 1 second M ...
- HDU 5875 Function 【倍增】 (2016 ACM/ICPC Asia Regional Dalian Online)
Function Time Limit: 7000/3500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total ...
- 训练报告 (2014-2015) 2014, Samara SAU ACM ICPC Quarterfinal Qualification Contest
Solved A Gym 100488A Yet Another Goat in the Garden B Gym 100488B Impossible to Guess Solved C Gym ...
- ACM ICPC Kharagpur Regional 2017
ACM ICPC Kharagpur Regional 2017 A - Science Fair 题目描述:给定一个有\(n\)个点,\(m\)条无向边的图,其中某两个点记为\(S, T\),另外标 ...
- 2017 ACM ICPC Asia Regional - Daejeon
2017 ACM ICPC Asia Regional - Daejeon Problem A Broadcast Stations 题目描述:给出一棵树,每一个点有一个辐射距离\(p_i\)(待确定 ...
- 2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest
2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest A - Arranging Wine 题目描述:有\(R\)个红箱和\(W\)个白箱,将这 ...
- 2017 ACM/ICPC Asia Regional Qingdao Online
Apple Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submi ...
- 2014嘉杰信息杯ACM/ICPC湖南程序设计邀请赛暨第六届湘潭市程序设计竞赛
比赛链接: http://202.197.224.59/OnlineJudge2/index.php/Contest/problems/contest_id/36 题目来源: 2014嘉杰信息杯ACM ...
随机推荐
- LeetCode 501. Find Mode in Binary Search Tree (找到二叉搜索树的众数)
Given a binary search tree (BST) with duplicates, find all the mode(s) (the most frequently occurred ...
- SIP简介,第1部分:SIP初探
说明:以下内容来着之前下载的一份文档,现将概念部分摘录在BLog,完成文档将放在文件中. SIP简介,第1部分:SIP初探 时间:2006-04-07作者:Emmanuel Proulx浏览次数: 2 ...
- Leetcode题解(十三)
36.Valid Sudoku 题目 代码如下: class Solution { public: bool isValidSudoku(vector<vector<char> &g ...
- C++ primer第五版随笔--2015年1月6日
记录自己看这本书时的一些内容. 一.引用(reference) 引用为对象起了另外一个名字.例如: int ival=1024: int &relVal1=ival;//对,注意尽量不要用这方 ...
- HDU 6143 Killer Names
Killer Names Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
- Pendant
Pendant Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submi ...
- 软硬链接、文件删除原理、linux中的三种时间、chkconfig优化
第1章 软硬链接 1.1 硬链接 1.1.1 含义 多个文件拥有相同的inode号码 硬链接即文件的多个入口 1.1.2 作用 防止你误删除文件 1.1.3 如何创建硬链接 ln 命令,前面是源文件 ...
- pie.htc 在IE下不起作用~~~
一直用的IE11 然后选择其中的兼容模式来测试IE 7~10的情况. 最近由于客户要求 圆角阴影兼容IE,只能选择PIE.HTC的方案. 但是反复测试发现不起作用. 官方文档的几种说明: 1. pie ...
- js个位数补0
//获取并格式化当前时间 var _getTime = function(){ var arr=['00','01','02','03','04','05','06','0,'08','09'], / ...
- 使用duilib开发简单的Window安装包
一.具体思路 安装过程:安装包的制作包括资源文件的打包,资源文件打包到安装包exe中,安装的时候需要从exe中提取出对应的资源文件, 然后解压文件安装到指定目录,然后就是对安装的可执行程序进行注册表的 ...