結果

問題 No.286 Modulo Discount Store
ユーザー mbanmban
提出日時 2017-04-28 16:21:00
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 1,145 bytes
コンパイル時間 2,187 ms
コンパイル使用メモリ 104,092 KB
実行使用メモリ 23,836 KB
最終ジャッジ日時 2023-10-11 18:54:29
合計ジャッジ時間 6,363 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
21,676 KB
testcase_01 AC 59 ms
19,652 KB
testcase_02 AC 61 ms
23,612 KB
testcase_03 AC 59 ms
21,676 KB
testcase_04 AC 58 ms
21,680 KB
testcase_05 AC 58 ms
21,640 KB
testcase_06 AC 62 ms
23,732 KB
testcase_07 AC 59 ms
21,576 KB
testcase_08 AC 58 ms
21,756 KB
testcase_09 AC 58 ms
21,676 KB
testcase_10 AC 60 ms
23,720 KB
testcase_11 AC 58 ms
21,736 KB
testcase_12 AC 59 ms
21,624 KB
testcase_13 AC 61 ms
23,616 KB
testcase_14 AC 59 ms
21,800 KB
testcase_15 AC 59 ms
23,836 KB
testcase_16 AC 58 ms
21,688 KB
testcase_17 AC 65 ms
23,580 KB
testcase_18 AC 59 ms
21,804 KB
testcase_19 AC 58 ms
21,564 KB
testcase_20 AC 59 ms
21,728 KB
testcase_21 AC 58 ms
21,624 KB
testcase_22 AC 59 ms
23,824 KB
testcase_23 AC 60 ms
21,672 KB
testcase_24 AC 58 ms
19,636 KB
testcase_25 AC 60 ms
23,672 KB
testcase_26 AC 58 ms
23,700 KB
testcase_27 AC 59 ms
23,612 KB
testcase_28 AC 62 ms
23,676 KB
testcase_29 AC 59 ms
21,560 KB
testcase_30 AC 60 ms
21,568 KB
testcase_31 AC 59 ms
21,628 KB
testcase_32 AC 59 ms
21,680 KB
testcase_33 AC 59 ms
21,724 KB
testcase_34 AC 58 ms
23,672 KB
testcase_35 AC 59 ms
21,644 KB
testcase_36 AC 59 ms
21,692 KB
testcase_37 AC 59 ms
21,676 KB
testcase_38 AC 59 ms
21,564 KB
testcase_39 AC 62 ms
21,684 KB
testcase_40 AC 59 ms
21,620 KB
testcase_41 AC 59 ms
23,720 KB
testcase_42 AC 58 ms
21,680 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

public class Program
{
    static private int N;
    static private int[] M;
    static private void Scan()
    {
        N = int.Parse(Console.ReadLine());
        M = new int[N];
        for (int i = 0; i < N; i++)
        {
            M[i] = int.Parse(Console.ReadLine());
        }
    }

    static public void Main(string[] args)
    {
        Scan();

        int[] dp = (new int[1 << N]).Select(i => int.MaxValue).ToArray();
        int[] teika = (new int[1 << N]).Select(i => int.MaxValue).ToArray();
        dp[0] = 0;
        teika[0] = 0;

        for (int i = 0; i < 1 << N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                int k = 1 << j;
                if ((i & k) > 0) continue;

                teika[i + k] = teika[i] + M[j];
                dp[i + k] = Math.Min(dp[i + k], dp[i] + Math.Max(0, M[j] - teika[i] % 1000));
            }
        }

        Console.WriteLine(dp[(1 << N) - 1]);
    }

}

0