結果

問題 No.733 分身並列コーディング
ユーザー りあんりあん
提出日時 2016-05-12 23:46:15
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,455 bytes
コンパイル時間 1,010 ms
コンパイル使用メモリ 106,880 KB
実行使用メモリ 22,912 KB
最終ジャッジ日時 2024-04-23 17:16:00
合計ジャッジ時間 4,806 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
21,552 KB
testcase_01 AC 22 ms
17,536 KB
testcase_02 AC 22 ms
17,408 KB
testcase_03 AC 60 ms
17,804 KB
testcase_04 AC 59 ms
17,800 KB
testcase_05 AC 36 ms
18,432 KB
testcase_06 AC 20 ms
17,792 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.IO;
using System.Text;

class Program
{
    static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        var sc = new Scan();
        int c = sc.Int;
        int n = sc.Int;
        var w = new int[n];
        var dp = new int[1 << n];
        var pl = new List<int>();
        for (int i = 0; i < n; i++)
            w[i] = sc.Int;
        
        for (int i = 1; i < (1 << n); i++)
        {
            int s = 0;
            for (int j = 0; j < n; j++)
                if ((i >> j & 1) == 1)
                    s += w[j];
            
            if (s <= c)
            {
                pl.Add(i);
                dp[i] = 1;
                continue;
            }
            dp[i] = n;
            foreach (var j in pl)
                if ((i & j) == j)
                    dp[i] = Math.Min(dp[i], dp[i ^ j] + 1);
        }
        sw.WriteLine(dp[(1 << n) - 1]);
        sw.Flush();
    }
}
class Scan
{
    public int Int { get { return int.Parse(Str); } }
    public long Long { get { return long.Parse(Str); } }
    public string Str { get { return Console.ReadLine().Trim(); } }
    public int[] IntArr { get { return StrArr.Select(int.Parse).ToArray(); } }
    public long[] LongArr { get { return StrArr.Select(long.Parse).ToArray(); } }
    public string[] StrArr { get { return Str.Split(); } }
}
0