結果
| 問題 | No.346 チワワ数え上げ問題 |
| コンテスト | |
| ユーザー |
okazuki
|
| 提出日時 | 2016-02-29 21:01:07 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 584 bytes |
| 記録 | |
| コンパイル時間 | 862 ms |
| コンパイル使用メモリ | 114,328 KB |
| 実行使用メモリ | 28,988 KB |
| 最終ジャッジ日時 | 2024-09-24 12:53:50 |
| 合計ジャッジ時間 | 2,390 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 3 WA * 20 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Linq;
namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
var s = Console.ReadLine();
var w = s.Count(x => x == 'w');
var answer = s.Reverse().Aggregate(0L, (sum, x) =>
{
if (x == 'w') { w--; }
if (x == 'c')
{
sum += w * (w - 1) / 2;
}
return sum;
});
Console.WriteLine(answer);
}
}
}
okazuki