URAL 1025 Democracy in Danger

排个序

 1 import java.util.Arrays;
 2 import java.util.Scanner;
 3
 4 public class P1025
 5 {
 6     public static void main(String args[])
 7     {
 8         try (Scanner cin = new Scanner(System.in))
 9         {
10             while (cin.hasNext())
11             {
12                 int n = cin.nextInt();
13                 int a[] = new int[n];
14                 for (int i = 0; i < n; i++)
15                     a[i] = cin.nextInt();
16                 Arrays.sort(a);
17                 int result = 0;
18                 for (int i = 0; i <= n / 2; i++)
19                     result += a[i] / 2 + 1;
20                 System.out.println(result);
21             }
22         }
23     }
24 }
时间: 2024-10-02 18:59:47

URAL 1025 Democracy in Danger的相关文章

URAL 1025. Democracy in Danger (贪心)

1025. Democracy in Danger Time limit: 1.0 second Memory limit: 64 MB Background In one of the countries of Caribbean basin all decisions were accepted by the simple majority of votes at the general meeting of citizens (fortunately, there were no lots

POJ2370 Democracy in danger

题目超级水,但题目意思不好理解(英语太差...),排个序,然后答案就出来了. Democracy in danger Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3136   Accepted: 2311 Description In one of the countries of Caribbean basin all decisions were accepted by the simple majority of

POJ 2370 Democracy in danger(简单贪心)

Democracy in danger Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3388   Accepted: 2508 Description In one of the countries of Caribbean basin all decisions were accepted by the simple majority of votes at the general meeting of citize

11 URAL1025 Democracy in Danger

选择人数较少的m/2只队,每只队中半数人投票. #include<cstdio> #include<algorithm> using namespace std; int main() { int i,n,ans,s[110]; while(~scanf("%d",&n)) { for(i=0;i<n;i++) scanf("%d",&s[i]); sort(s,s+n); ans=0; for(i=0;i<=n/

poj 2370 Democracy in danger

题目链接:http://poj.org/problem?id=2370 题意:大意好像是类似选举,给出K,表示一共K组,然后给出K组人每组的人数,都是奇数.每组人有超过一半的人同意就认为那一组人同意,有超过半数的组同意就决定通过,看最少要多少人同意能决定通过. 分析:贪心.(水)将每组人数按照从小到大排序,选择前面(k)/2+1组人每组a[i]/2+1的人同意就好. 代码: #include<cstdio> #include<cmath> #include<cstring&g

ACM训练方案-POJ题目分类

ACM训练方案-POJ题目分类 博客分类: 算法 ACM online Judge 中国: 浙江大学(ZJU):http://acm.zju.edu.cn/ 北京大学(PKU):http://acm.pku.edu.cn/JudgeOnline/ 杭州电子科技大学(HDU):http://acm.hdu.edu.cn/ 中国科技大学(USTC):http://acm.ustc.edu.cn/ 北京航天航空大学(BUAA)http://acm.buaa.edu.cn/oj/index.php 南京

HDU——PKU题目分类

HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201

(转载)ACM训练计划,先过一遍基础再按此拼搏吧!!!!

ACM大量习题题库 ACM大量习题题库 现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge.除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库. USACO http://ace.delos.com/usacogate 美国著名在线题库,专门为信息学竞赛选手准备 TJU http://acm.tongji.edu.cn/ 同济大学在线题库,唯一的中文题库,适合NOIP选手 ZJU http://acm.zju.edu.cn/ 浙江大学在线题库 JLU htt

北大ACM题库习题分类与简介(转载)

在百度文库上找到的,不知是哪位大牛整理的,真的很不错! zz题 目分类 Posted by fishhead at 2007-01-13 12:44:58.0 -------------------------------------------------------------------------------- acm.pku.edu.cn 1. 排序 1423, 1694, 1723, 1727, 1763, 1788, 1828, 1838, 1840, 2201, 2376, 23