結果
問題 |
No.733 分身並列コーディング
|
ユーザー |
![]() |
提出日時 | 2016-05-12 23:46:15 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,455 bytes |
コンパイル時間 | 1,161 ms |
コンパイル使用メモリ | 112,864 KB |
実行使用メモリ | 22,656 KB |
最終ジャッジ日時 | 2024-10-15 17:49:07 |
合計ジャッジ時間 | 4,727 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 4 TLE * 1 -- * 41 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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(); } } }