結果

問題 No.45 回転寿司
ユーザー ooh_20ooh_20
提出日時 2017-06-05 12:30:57
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 1,248 bytes
コンパイル時間 905 ms
コンパイル使用メモリ 110,756 KB
実行使用メモリ 25,900 KB
最終ジャッジ日時 2023-10-22 05:31:19
合計ジャッジ時間 3,210 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 WA -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 WA -
testcase_12 RE -
testcase_13 RE -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 RE -
testcase_19 RE -
testcase_20 WA -
testcase_21 RE -
testcase_22 AC 31 ms
25,540 KB
testcase_23 AC 31 ms
25,540 KB
testcase_24 AC 31 ms
25,540 KB
testcase_25 AC 30 ms
25,444 KB
testcase_26 RE -
testcase_27 WA -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 WA -
testcase_32 AC 31 ms
25,540 KB
testcase_33 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Text;
using System.Threading.Tasks;

namespace No._45
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] V = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray();
            int[] sortArray = new int[N];
            int sum = 0;

            V.CopyTo(sortArray, 0);
            Array.Sort(sortArray);
            Array.Reverse(sortArray);

            for (int i = 0; i < N; i++)
            {
                if (sortArray[i] == 0)
                {
                    continue;
                }

                int buff = Array.IndexOf(V, sortArray[i]);
                sum += V[buff];
                V[buff] = 0;

                if (buff - 1 >= 0)
                {
                    sortArray[Array.IndexOf(sortArray, V[buff - 1])] = 0;
                    V[buff - 1] = 0;
                }
                if (buff + 1 < N)
                {
                    sortArray[Array.IndexOf(sortArray, V[buff + 1])] = 0;
                    V[buff + 1] = 0;
                }
            }

            Console.WriteLine(sum);
        }
    }
}
0