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 ...
随机推荐
- 【Mybatis框架】查询缓存(一级缓存)
做Java的各位程序员们,估计SSH和SSM是我们的基础必备框架.也就是说我们都已经至少接触过了这两套常见的集成框架.当我们用SSH的时候,相信很多人都接触过hibernate的两级缓存,同样,相对应 ...
- Centos7 基本shell命令
删除文件 # rm /usr/local/test.txt# rm -f /usr/local/test.txt //强制删除文件,不弹出提示 移动文件或文件夹 # mv webdata /bin/u ...
- xml转义字符
解析XML文件时,如果有多个转义学符可以用 <![CDATA[含有转义字符的内容]]
- VB下对HTML元素的操作
<!DOCTYPE html> <html> <head> <title>test</title> </head> <bo ...
- dojo tree edit的使用[前端]
var store = new mydata.JsonRestStore({ target: "<%=ResolveUrl("~/uieditserver.ashx" ...
- Hibernate学习笔记4
一.关于联合主键的映射测试实例 实体类: package com.***.comBineKey;public class Person { private Person_pk pk; private ...
- php获取html纯文本,解决编辑器手动键入空格造成的无意义空白字符(空值问题)
在项目中,我们常常需要用到一些验证,不管是前台还是后台的,上传的问题时,需要内容不为空,但可视化编辑器的介入让手动敲入空格跳出了常规的检测.空格是一种排版的手段,但毫无内容只有空格就显得没有意义了,今 ...
- js获取浏览器前缀
<script> var div = null; var _prefix = (function (temp) { var prefix = ["webkit", &q ...
- python 基础
Python基础 三元运算(三目运算),是对简单的条件语句的缩写. # 书写格式 result = 值1 if 条件 else 值2 # 如果条件成立,那么将 “值1” 赋值给result变量,否则, ...
- python3 抓取网页资源的 N 种方法
1. 最简单 import urllib.request response = urllib.request.urlopen('http://python.org/') html = response ...