結果

問題 No.710 チーム戦
ユーザー Tomohiko HasegawaTomohiko Hasegawa
提出日時 2019-03-30 15:37:31
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 160 ms / 3,000 ms
コード長 2,163 bytes
コンパイル時間 1,038 ms
コンパイル使用メモリ 64,104 KB
実行使用メモリ 42,524 KB
最終ジャッジ日時 2023-08-09 19:47:52
合計ジャッジ時間 6,130 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
21,752 KB
testcase_01 AC 62 ms
22,632 KB
testcase_02 AC 149 ms
42,524 KB
testcase_03 AC 148 ms
42,372 KB
testcase_04 AC 144 ms
40,340 KB
testcase_05 AC 140 ms
42,348 KB
testcase_06 AC 141 ms
42,360 KB
testcase_07 AC 141 ms
38,316 KB
testcase_08 AC 144 ms
42,348 KB
testcase_09 AC 144 ms
40,376 KB
testcase_10 AC 147 ms
42,316 KB
testcase_11 AC 145 ms
40,484 KB
testcase_12 AC 148 ms
42,360 KB
testcase_13 AC 145 ms
40,400 KB
testcase_14 AC 139 ms
40,364 KB
testcase_15 AC 144 ms
42,292 KB
testcase_16 AC 147 ms
42,500 KB
testcase_17 AC 139 ms
40,296 KB
testcase_18 AC 147 ms
40,268 KB
testcase_19 AC 142 ms
42,352 KB
testcase_20 AC 143 ms
42,328 KB
testcase_21 AC 139 ms
40,320 KB
testcase_22 AC 125 ms
42,392 KB
testcase_23 AC 125 ms
42,340 KB
testcase_24 AC 160 ms
42,412 KB
testcase_25 AC 58 ms
20,876 KB
testcase_26 AC 59 ms
20,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.DP
{
    class yuki710
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[][] abs = new int[n][];
            for(int i = 0; i < n; i++)
            {
                abs[i] = ReadInts();
            }
            int length = 100000 + 1000;
            int inf = int.MaxValue / 4;
            int[] dp = new int[length];
            for (int i = 0; i < length; i++) dp[i] = inf;
            dp[0] = 0;
            for (int i = 0; i < n; i++)
            {
                int[] next = new int[length];
                for (int j = 0; j < length; j++) next[j] = inf;
                for (int j = 0; j < length; j++)
                {
                    if (dp[j] == inf) continue;

                    next[j] = Min(next[j], dp[j] + abs[i][1]);
                    int nextIndex = j + abs[i][0];
                    if (nextIndex < length)
                    {
                        next[nextIndex] = Min(next[nextIndex], dp[j]);
                    }
                }
                dp = next;
            }
            int min = int.MaxValue;
            for(int i = 0; i < length; i++)
            {
                min = Min(min, Max(i, dp[i]));
                //if (i <= 10) WriteLine(dp[i]);
            }
            WriteLine(min);
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}
0