結果
問題 | No.115 遠足のおやつ |
ユーザー | mban |
提出日時 | 2017-01-12 08:25:37 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,692 bytes |
コンパイル時間 | 962 ms |
コンパイル使用メモリ | 115,320 KB |
実行使用メモリ | 334,688 KB |
最終ジャッジ日時 | 2024-12-21 10:07:02 |
合計ジャッジ時間 | 11,090 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | AC | 26 ms
25,056 KB |
testcase_02 | AC | 30 ms
25,100 KB |
testcase_03 | RE | - |
testcase_04 | AC | 476 ms
101,096 KB |
testcase_05 | AC | 28 ms
25,044 KB |
testcase_06 | AC | 26 ms
24,936 KB |
testcase_07 | AC | 30 ms
25,000 KB |
testcase_08 | AC | 33 ms
29,028 KB |
testcase_09 | AC | 109 ms
45,604 KB |
testcase_10 | AC | 173 ms
55,444 KB |
testcase_11 | AC | 26 ms
25,180 KB |
testcase_12 | AC | 125 ms
48,812 KB |
testcase_13 | AC | 26 ms
26,876 KB |
testcase_14 | AC | 32 ms
27,328 KB |
testcase_15 | AC | 251 ms
65,524 KB |
testcase_16 | AC | 347 ms
86,876 KB |
testcase_17 | AC | 91 ms
42,400 KB |
testcase_18 | AC | 27 ms
24,800 KB |
testcase_19 | AC | 38 ms
28,188 KB |
testcase_20 | AC | 29 ms
25,012 KB |
testcase_21 | AC | 71 ms
40,368 KB |
testcase_22 | AC | 201 ms
63,292 KB |
testcase_23 | AC | 30 ms
27,104 KB |
testcase_24 | AC | 132 ms
45,220 KB |
testcase_25 | AC | 90 ms
42,868 KB |
testcase_26 | AC | 43 ms
33,260 KB |
testcase_27 | AC | 57 ms
34,596 KB |
testcase_28 | AC | 44 ms
33,096 KB |
testcase_29 | AC | 100 ms
43,648 KB |
testcase_30 | AC | 157 ms
48,696 KB |
testcase_31 | AC | 146 ms
51,612 KB |
testcase_32 | AC | 298 ms
75,932 KB |
testcase_33 | AC | 49 ms
35,808 KB |
testcase_34 | AC | 463 ms
97,064 KB |
testcase_35 | AC | 174 ms
56,100 KB |
testcase_36 | AC | 94 ms
40,136 KB |
testcase_37 | AC | 388 ms
92,116 KB |
testcase_38 | AC | 2,019 ms
317,016 KB |
testcase_39 | AC | 2,196 ms
334,688 KB |
testcase_40 | RE | - |
testcase_41 | AC | 26 ms
27,100 KB |
testcase_42 | AC | 27 ms
26,948 KB |
コンパイルメッセージ
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; using System.Collections.Generic; using System.Collections.Specialized; using System.Text; using System.Text.RegularExpressions; using System.Linq; using System.IO; class Program { static private Magatro M = new Magatro(); static private void Main(string[]args) { M.Scan(); M.Solve(); } } public class Scanner { private string[] S; private int Index; private char Separator; public Scanner(char separator = ' ') { Index = 0; Separator = separator; } private string[] Line() { return Console.ReadLine().Split(Separator); } public string Next() { string result; if (S == null || Index >= S.Length) { S = Line(); Index = 0; } result = S[Index]; Index++; return result; } public int NextInt() { return int.Parse(Next()); } public double NextDouble() { return double.Parse(Next()); } public long NextLong() { return long.Parse(Next()); } } public class Magatro { private int N, D, K; public void Scan() { Scanner sc = new Scanner(); N = sc.NextInt(); D = sc.NextInt(); K = sc.NextInt(); } public void Solve() { //合計,N個目,N個買った Count[,,] dp = new Count[(D + 1), (N + 1), (N + 1)]; dp[0, 0, 0].Buy = new List<int>(); for (int i = 1; i <= N; i++) { for (int j = 0; j <= D; j++) { for (int k = 0; k < i; k++) { if (dp[j, i - 1, k].Buy == null) continue; Count cp = dp[j, i - 1, k].Copy(); dp[j, i, k] = Min(dp[j, i, k], cp); cp.Buy.Add(i); if (j + i > D) continue; dp[j + i, i, k + 1] = Min(cp, dp[j + i, i, k + 1]); } } } List<int> ans = dp[D, N, K].Buy; if (ans == null || ans.Count == 0) Console.WriteLine(-1); else Console.WriteLine(string.Join(" ",ans)); } private Count Min(Count a, Count b) { if (a.Buy == null) return b.Copy(); if (b.Buy == null) return a.Copy(); for (int i = 0; i < a.Buy.Count; i++) { if (a.Buy[i] < b.Buy[i]) return a.Copy(); else if (a.Buy[i] > b.Buy[i]) return b.Copy(); } return a.Copy(); } } public struct Count { public List<int> Buy; public Count Copy() { Count ret; ret.Buy = Buy.ToList(); return ret; } }