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 ...
随机推荐
- YARN-MR 大数据第二天
大数据第二天 1.YARN(管理和调度集群中的各类资源) 1.1 产生的背景: 1.直接源于MR版本1的缺陷(如:单点故障.难以支持MR之外的计算框架等) 2.多计算框架各自为站,数据共享困难(如:M ...
- Go语言 使用内置Http组件
package main import ( "net/http" ) func SayHello(w http.ResponseWriter, req *http.Request) ...
- 分布式缓存技术redis学习系列(五)——redis实战(redis与spring整合,分布式锁实现)
本文是redis学习系列的第五篇,点击下面链接可回看系列文章 <redis简介以及linux上的安装> <详细讲解redis数据结构(内存模型)以及常用命令> <redi ...
- [NOIP2016]换教室 D1 T3 Floyed+期望DP
[NOIP2016]换教室 D1 T3 Description 对于刚上大学的牛牛来说, 他面临的第一个问题是如何根据实际情况中情合适的课程. 在可以选择的课程中,有2n节课程安排在n个时间段上.在第 ...
- 【NOI2016】优秀的拆分 题解(95分)
题目大意: 求一个字符串中形如AABB的子串个数. 思路: 用哈希做到O(1)判断字符串是否相同,O($n^2$)预处理,ans[i]为开头位置为i的形如AA的子串个数.再用O($n^2$)枚举出AA ...
- 【贪心】SOJ 13983
SOJ 13983. Milk Scheduling 这是比赛题,还是作死的我最讨厌的英文题,题目大意就是有n头奶牛,要在喂奶截止时间前给他喂奶并得到相应的含量的牛奶. 一开始的想法就是挑选截止日期的 ...
- HTML5 meta最全使用手册
1.声明文档使用的字符编码 <meta charset='utf-8'> 2.声明文档的兼容模式 <meta http-equiv="X-UA-Compatible&quo ...
- Simplify Path
Given an absolute path for a file (Unix-style), simplify it. For example, path = "/home/", ...
- phpcms开发过程中遇到的问题总结
1.Q:phpcms后台页面使用ajax会进不了控制器方法中 A:因为后台安全性比较高,需要进行hash验证,直接在浏览器输入ajax要访问的路径就会出现如下图的报错.所以后台页面尽可能用其他方法 ...
- maven模块
用maven无它,唯方便而. 模块依赖可以用来做一些公共模块,多个工程调用. 先子模块 install 或者package.在父模块install