結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-28 18:58:26 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 19 ms / 2,000 ms |
| コード長 | 819 bytes |
| コンパイル時間 | 957 ms |
| コンパイル使用メモリ | 108,596 KB |
| 実行使用メモリ | 17,920 KB |
| 最終ジャッジ日時 | 2024-07-08 00:28:46 |
| 合計ジャッジ時間 | 2,241 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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);
}
}
}