結果

問題 No.45 回転寿司
ユーザー hogekihogeki
提出日時 2016-07-31 23:28:45
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,379 bytes
コンパイル時間 4,301 ms
コンパイル使用メモリ 109,812 KB
実行使用メモリ 99,732 KB
最終ジャッジ日時 2024-05-03 15:30:52
合計ジャッジ時間 11,786 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 55 ms
35,684 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 123 ms
44,756 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 99 ms
41,180 KB
testcase_12 WA -
testcase_13 AC 51 ms
35,676 KB
testcase_14 AC 45 ms
33,640 KB
testcase_15 WA -
testcase_16 AC 139 ms
49,100 KB
testcase_17 WA -
testcase_18 AC 146 ms
48,848 KB
testcase_19 WA -
testcase_20 AC 46 ms
35,684 KB
testcase_21 AC 54 ms
35,552 KB
testcase_22 AC 29 ms
26,040 KB
testcase_23 AC 29 ms
26,020 KB
testcase_24 AC 29 ms
25,892 KB
testcase_25 AC 29 ms
27,980 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 30 ms
28,200 KB
testcase_32 AC 31 ms
28,208 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;

namespace KaitenZushi
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] V = new int[N];
            string[] vals = Console.ReadLine().Split(' ');

            for(int i=0; i < N; i++)
            {
                V[i] = int.Parse(vals[i]);
            }

            List<int>[] dp = new List<int>[100101];
            for(int i=0; i <= 100100; i++)
            {
                dp[i] = new List<int>();
            }

            int maxValue = 0;

            for(int i=0; i < N; i++)
            {
                for(int v=10000; v >= 0; v--)
                {
                    if(v == 0 || CheckList(dp[v], i))
                    {
                        int val = v + V[i];
                        dp[val].Add(i);
                        if (maxValue < val)
                            maxValue = val;
                    }
                }
            }

            Console.WriteLine(maxValue);
            
        }

        static bool CheckList(List<int> list, int i)
        {
            if (list.Count == 0)
                return false;

            foreach(int j in list)
            {
                if (j != i - 1)
                    return true;
            }
            return false;
        }
    }
}
0