結果

問題 No.45 回転寿司
ユーザー MoonOnRainMoonOnRain
提出日時 2018-05-21 21:23:35
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,016 bytes
コンパイル時間 4,245 ms
コンパイル使用メモリ 107,440 KB
実行使用メモリ 30,168 KB
最終ジャッジ日時 2023-09-11 01:04:22
合計ジャッジ時間 9,149 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 RE -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 RE -
testcase_07 WA -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 WA -
testcase_13 RE -
testcase_14 WA -
testcase_15 RE -
testcase_16 WA -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 WA -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 WA -
testcase_30 RE -
testcase_31 WA -
testcase_32 AC 65 ms
21,900 KB
testcase_33 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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);
    }

    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 != sushiList.Count)
        {
            sushiList[deliciousSushi.Index + 1] = 0;
        }

        if(deliciousSushi.Index != 0)
        {
            sushiList[deliciousSushi.Index - 1] = 0;
        }

        return deliciousSushi.Sushi;
    }
}
0