結果
| 問題 | No.45 回転寿司 |
| ユーザー |
|
| 提出日時 | 2018-05-21 21:26:36 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,046 bytes |
| 記録 | |
| コンパイル時間 | 920 ms |
| コンパイル使用メモリ | 109,056 KB |
| 実行使用メモリ | 23,936 KB |
| 最終ジャッジ日時 | 2024-06-28 15:35:59 |
| 合計ジャッジ時間 | 3,341 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 1 WA * 29 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
public class Amatsuki
{
private static List<int> sushiList;
public static void Main()
{
Console.ReadLine();
sushiList = Console.ReadLine().Split(new char[] {' '}).Select(x => int.Parse(x)).ToList();
var eatenSushi = 0;
do
{
eatenSushi += TakeSushi();
} while (sushiList.Sum() != 0);
Console.WriteLine(eatenSushi);
Console.ReadKey();
}
private static int TakeSushi()
{
var deliciousSushi = sushiList
.Select((x, i) => new { Index = i, Sushi = x })
.OrderByDescending(x => x.Sushi)
.First();
sushiList[deliciousSushi.Index] = 0;
if(deliciousSushi.Index + 1 < sushiList.Count)
{
sushiList[deliciousSushi.Index + 1] = 0;
}
if(deliciousSushi.Index != 0)
{
sushiList[deliciousSushi.Index - 1] = 0;
}
return deliciousSushi.Sushi;
}
}