結果
| 問題 | No.345 最小チワワ問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-28 18:58:26 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 14 ms / 2,000 ms |
| コード長 | 819 bytes |
| 記録 | |
| コンパイル時間 | 774 ms |
| コンパイル使用メモリ | 104,064 KB |
| 実行使用メモリ | 18,176 KB |
| 最終ジャッジ日時 | 2026-03-29 16:04:57 |
| 合計ジャッジ時間 | 2,034 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
namespace _0345
{
class Program
{
static void Main(string[] args)
{
var s = Console.ReadLine();
var ans = int.MaxValue;
for(var i = 0; i < s.Length; i++){
if(s[i] == 'c'){
var cnt = 1;
var w = 0;
for(var j = i + 1; j < s.Length; j++){
cnt++;
if(s[j] == 'w'){
w++;
if(w == 2){
ans = Math.Min(ans,cnt);
break;
}
}
}
}
}
Console.WriteLine(ans != int.MaxValue ? ans: -1);
}
}
}