結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
bluemegane
|
| 提出日時 | 2020-09-04 07:49:05 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 23 ms / 2,000 ms |
| コード長 | 534 bytes |
| コンパイル時間 | 4,218 ms |
| コンパイル使用メモリ | 106,252 KB |
| 実行使用メモリ | 25,944 KB |
| 最終ジャッジ日時 | 2024-11-24 23:18:09 |
| 合計ジャッジ時間 | 3,288 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
public class hello
{
static void Main()
{
var s = Console.ReadLine().Trim();
var sL = s.Length;
var wc = new long[sL];
var ans = 0L;
if (s[sL - 1] == 'w') wc[sL - 1] = 1;
if (sL > 2)
{
for (int i = sL - 2; i >= 0; i--)
{
wc[i] = wc[i + 1];
if (s[i] == 'w') wc[i]++;
else if (s[i] == 'c') ans += wc[i] * (wc[i] - 1) / 2;
}
}
Console.WriteLine(ans);
}
}
bluemegane