HDOJ 1004 Let the Balloon Rise
Problem Description
This year, they decide to leave this lovely job to you.
A test case with N = 0 terminates the input and this test case is not to be processed.
green
red
blue
red
red
3
pink
orange
pink
0
pink
思路
还好AC了。
1
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text; namespace hdoj {
class Programweb {
private static StringBuilder sb = new StringBuilder();
static void Main(string[] args) {
// //DateTime d1 = DateTime.Now;//local
// var lines = File.ReadLines("input2.txt").ToList();//local
int num = ; int lineIndex = ;
int lineNumIndex = -;
//获取行数
while (true) {
string s1 = "";
List<string> keys = new List<string>();
List<int> values = new List<int>();
bool keyExist = false;
int index = ;
// int max = 0;
if (int.TryParse(Console.ReadLine(), out num)) {//web
// lineNumIndex = lineNumIndex + num + 1;//local 指示数字行所在的行数=之前数字行所在的位置+上次的行数+数字本身的站1行
// if (int.TryParse(lines[lineNumIndex], out num)) {//local
for (int i = ; i < num; i++) {
s1 = Console.ReadLine();//web
// s1 = lines[i + lineNumIndex+1]; //local
// handOneLine(s1, i,num);
for (int j = ; j < keys.Count; j++) {
if (keys[j] == s1) {
keyExist = true;
index = j;
break;
} else {
keyExist = false;
}
}
//是否存在不同处理
if (keyExist) {
values[index]++;
if (values[index] > num / ) {
// max = index;
break;
}
} else {
keys.Add(s1);
values.Add();
} } if (num == ) {
break;
} //一次结束
if (values.Count != ) {
int max = ;
int maxIndex = ;
for (int i = ; i < values.Count; i++) {
if (values[i]>max) {
maxIndex = i;
max = values[i];
}
}
sb.AppendLine(keys[maxIndex]);
}
keys.Clear();
values.Clear(); //
// sb.AppendLine(string.Format("Case {0}:", i));
//sb.AppendLine(); } } Console.Write(sb.ToString()); //DateTime d2 = DateTime.Now;
//TimeSpan ts1 = d2 - d1;
//Console.WriteLine("Milliseconds:" + ts1.Milliseconds);
// Console.Read();//local
} } }
2
HDOJ 1004 Let the Balloon Rise的更多相关文章
- HDOJ 1004 Let the Balloon Rise (字符串+stl)
题目: Problem Description Contest time again! How excited it is to see balloons floating around. But t ...
- hdu 1004 Let the Balloon Rise(字典树)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...
- HDU 1004 Let the Balloon Rise(map的使用)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...
- HDU 1004 Let the Balloon Rise【STL<map>】
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- hdu 1004 Let the Balloon Rise
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- HDU 1004 Let the Balloon Rise map
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- hdu 1004 Let the Balloon Rise strcmp、map、trie树
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- 杭电1004 Let the Balloon Rise
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- hduoj#1004 -Let the Balloon Rise [链表解法]
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 Problem Description Contest time again! How exci ...
随机推荐
- 基于socket的客户端和服务端聊天简单使用 附Demo
功能使用 服务端 分离一个不停接受客户端请求的线程 接受不客户端请求的线程中,再分离就收消息的线程 几大对象分别是 IPEndPoint IP终结点 服务端Socket,绑定终结点Bind,启动监听L ...
- jQuery插件(拖拽)
拖曳插件draggable的功能是拖动被绑定的元素,当这个jQuery UI插件与元素绑定后,可以通过调用draggable()方法,实现各种拖曳元素的效果,调用格式如下: $(selector). ...
- CSS Table Gallery
http://icant.co.uk/csstablegallery/tables/99.php
- 【BZOJ】3737: [Pa2013]Euler
题意: 求满足\(phi(a)=n\)的\(a\)的个数.(\(n \le 10^{10}\)) 分析 这种题一开始就感觉是搜索= = 题解 首先容易得到 \[\phi(n) = \prod_{i} ...
- 初玩Linux部署项目
1,先安装虚拟机2,安装centOS3,安装mysql 安装mysql客户端: yum install mysql 安装mysql 服务器端: yum install mysql-server yum ...
- 【Alpha】Daily Scrum Meeting总结
一.项目预期计划和现实进展 项目预期计划 现实进展 登陆 完成 使用菜单 完成 查看自己的信息 完成(额外完成可修改) 完成能用的界面 完成(额外美化) 可以导入导出表格 导入表格完成,导出未完成 教 ...
- <六>JDBC_DAO 设计模式
JDBC_DAO设计模式 DAO:Data Access Object(数据访问对象) why:实现功能的模块化,更有利于代码的维护和升级. what:访问数据信息的类,包含了对数据的CRUD(c ...
- sql例子
select * from plat_material_resource where stl_url LIKE '/data1/upload%' --截取字符串 UPDATE plat_materia ...
- 安卓中級教程(9):pathbutton中的animation.java研究(2)
src/geniuz/myPathbutton/composerLayout.java package geniuz.myPathbutton; import com.nineoldandroids. ...
- php如何查看变量是真实被引用
$var1 = 'Hello World'; $var2 = ''; $var2 =&$var1; debug_zval_dump(&$var1); $a = "aaa&qu ...