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 ...
随机推荐
- MVC 好记星不如烂笔头之 ---> 页面压缩GIP
public class BaseController : Controller { /// <summary> /// Called before the action method i ...
- Android ImageView的scaleType属性与adjustViewBounds属性(转)
ImageView的scaleType的属性有好几种,分别是matrix(默认).center.centerCrop.centerInside.fitCenter.fitEnd.fitStart.fi ...
- MIT 6.828 JOS学习笔记9. Exercise 1.5
Lab 1 Exercise 5 再一次追踪一下boot loader的一开始的几句指令,找到第一条满足如下条件的指令处: 当我修改了boot loader的链接地址,这个指令就会出现错误. 找到这样 ...
- StringEscapeUtils类的转义与反转义方法
第一步.下载Jar包(commons-lang.jar) 下载地址:http://commons.apache.org/proper/commons-lang/download_lang.cgi 第二 ...
- Codeforces 717G Underfail(最小费用最大流 + AC自动机)
题目 Source http://codeforces.com/problemset/problem/717/G Description You have recently fallen throug ...
- [Leetcode] Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' - ...
- 【BZOJ1503】[HAOI2007]反素数ant 搜索
结论题...网上讲的好的很多... #include <iostream> using namespace std; ]={,,,,,,,,,},num=; long long ans,n ...
- php+ajax 登录注册页面
主要是登录注册功能,前端后台验证没有什么,这个大家可以自己加上去,比如过滤啊,正则啊等 还是先放图吧 这是登录及注册界面 点击注册切换到注册界面,点击登录切换到登录界面 <!DOCTYPE h ...
- bzoj 4503 两个串
Description 兔子们在玩两个串的游戏.给定两个字符串S和T,兔子们想知道T在S中出现了几次, 分别在哪些位置出现.注意T中可能有“?”字符,这个字符可以匹配任何字符. Input 两行两个字 ...
- MySQL配置文件my.cnf 例子最详细翻译
转的 MySQL配置文件my.cnf 例子最详细翻译,可以保存做笔记用. #BEGIN CONFIG INFO#DESCR: 4GB RAM, 只使用InnoDB, ACID, 少量的连接, 队列负载 ...