結果
| 問題 |
No.342 一番ワロタww
|
| コンテスト | |
| ユーザー |
重荷
|
| 提出日時 | 2016-03-29 23:44:11 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 23 ms / 5,000 ms |
| コード長 | 1,236 bytes |
| コンパイル時間 | 813 ms |
| コンパイル使用メモリ | 105,472 KB |
| 実行使用メモリ | 17,792 KB |
| 最終ジャッジ日時 | 2024-10-15 13:22:51 |
| 合計ジャッジ時間 | 1,986 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
public struct KusaItem{
public string word;
public int kusaCnt;
public KusaItem(string word,int kusaCnt){
this.word=word;
this.kusaCnt=kusaCnt;
}
}
class Kusa{
static void Main(){
char[] chars = Console.ReadLine().ToCharArray();
List<KusaItem> list = new List<KusaItem>();
int cnt=0;
string str="";
for(int i=0;i<chars.Length;i++){
if(chars[i] != 'w') {
//Console.WriteLine(chars[i]);
str+=chars[i];
cnt=0;
} else {
cnt++;
if((chars.Length-1 > i && chars[i+1] != 'w') || chars.Length-1 <= i){
list.Add(new KusaItem(str,cnt));
str="";
}
}
}
int max=0;
//linqでやりたかった(´・ω・`)
foreach(var item in list)
if((max < item.kusaCnt) && !String.IsNullOrWhiteSpace(item.word)) max = item.kusaCnt;
foreach(KusaItem item in list){
if(item.kusaCnt == max && !String.IsNullOrWhiteSpace(item.word)) Console.WriteLine(item.word);
}
}
}
重荷