結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-10-27 17:57:06 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 713 bytes |
| コンパイル時間 | 5,269 ms |
| コンパイル使用メモリ | 101,888 KB |
| 実行使用メモリ | 17,920 KB |
| 最終ジャッジ日時 | 2024-11-21 21:20:41 |
| 合計ジャッジ時間 | 6,278 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 WA * 1 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
public class Program {
public void Solve() {
char[] c = Console.ReadLine().ToCharArray();
int min = c.Length;
for (int i = 0; i < c.Length; i++) {
int count = 0;
int w = 0;
if (c[i].Equals('c')) {
count++;
for (int j = i + 1; j < c.Length; j++) {
count++;
if (c[j].Equals('c') && w == 0) {
i = j - 1;
break;
} else if (c[j].Equals('w')) {
w++;
if (w == 2 && count < min) {
min = count;
break;
}
}
}
}
}
if (min == c.Length) {
Console.WriteLine(-1);
} else {
Console.WriteLine(min);
}
}
public static void Main(string[] args) {
Program program = new Program();
program.Solve();
}
}