[CodeForces 160A] Twins
题目链接:http://codeforces.com/problemset/problem/160/A
注意排序是从大到小排,不要上来就sort导致从小到大排,细节水题。
AC代码:
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int arr[101];
int n;
bool cmp(int a,int b) {
    return a > b;
}
int main() {
    while(scanf("%d",&n) != EOF && (n>=1 && n <= 100)) {
        int sum = 0;
        for(int i = 0;i < n;i++) {
            scanf("%d",&arr[i]);
            sum += arr[i];
        }
        int temp = 0;
        int flag = 0;
        sort(arr,arr+n,cmp);
        for(int i = 0;i < n;i++) {
            temp += arr[i];
            sum -= arr[i];
            flag++;
            if(temp > sum)
                break;
        }
        printf("%d\n",flag);
    }
    return 0;
}
[CodeForces 160A] Twins的更多相关文章
- python爬虫学习(5) —— 扒一下codeforces题面
		上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ... 
- 【Codeforces 738D】Sea Battle(贪心)
		http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ... 
- 【Codeforces 738C】Road to Cinema
		http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ... 
- 【Codeforces 738A】Interview with Oleg
		http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ... 
- CodeForces - 662A Gambling Nim
		http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ... 
- CodeForces - 274B Zero Tree
		http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ... 
- CodeForces - 261B Maxim and Restaurant
		http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ... 
- CodeForces - 696B Puzzles
		http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ... 
- CodeForces - 148D Bag of mice
		http://codeforces.com/problemset/problem/148/D 题目大意: 原来袋子里有w只白鼠和b只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ... 
随机推荐
- java处理jqueryGantt甘特图数据的task.depends依赖规则方法
			前端采用jqueryGantt,github地址为:https://github.com/robicch/jQueryGantt 原以为后端只需要简单地保存甘特图任务列表和返回任务列表就行了. 但功能 ... 
- Flutter Swiper制作轮播效果
			1.引入flutter_swiper插件 flutter最强大的siwiper, 多种布局方式,无限轮播,Android和IOS双端适配. Flutter_swiper的GitHub地址:https: ... 
- [Paper Reading] Show and Tell: A Neural Image Caption Generator
			论文链接:https://arxiv.org/pdf/1411.4555.pdf 代码链接:https://github.com/karpathy/neuraltalk & https://g ... 
- 《剑指offer》Q13-18 (牛客10.13)
			目录 Q13 调整数组顺序使奇数位于偶数前 Q14 链表中倒数第k个结点 Q15 反转链表 Q16 合并两个有序链表 Q17 树的子结构 Q18 二叉树的镜像 Q13 调整数组顺序使奇数位于偶数前 输 ... 
- NDK学习笔记-JNI的异常处理与缓存策略
			在使用JNI的时候,可能会产生异常,此时就需要对异常进行处理 异常处理 JNI抛出Throwable异常,在Java层可以用Throwable捕捉 而在C只有清空异常这种处理 但如果在JNI中通过Th ... 
- mongodb 连接后无法使用 发现已经有进程在运行
			mongod 命令执行发现已经有进程在运行mongod数据库--errno:48 Address already in use for socket: 0.0.0.0:27017 错误信息: list ... 
- java知识随笔整理-数据库的临时表
			1.创建临时表的方法 方法一.select * into #临时表名 from 你的表; 方法二. create table #临时表名(字段1 约束条件,字段2 约束条件,.....)create ... 
- Oracle的查询-子查询
			--子查询 --子查询返回一个值 --查询出工资和scott一样的员工信息 select * from emp where sal in (select sal from emp where enam ... 
- [DEBUG] spring boot在eclipse中用maven打包成jar访问templates报500错误
			更新:打war包的话只要把html文件放在resources/templates下即可,根本不需要放外面. 配置application.yml和templates放外面这种做法,打war包确实不行. ... 
- Symfony 服务配置 看这一篇就够了
			对于刚接触 Symfony 的新手来说,如何配置服务是一件很困难的事情.虽然在 Symfony 的新版本的框架中加入了自动加载(autowire),基本上满足了一般的需求,但是如果你想深入了解“服务” ... 
