Submission #581693


Source Code Expand

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Numerics;
 
namespace Solver
{
    class Program
    {
        const int M = 1000000007;
        const double eps = 1e-9;
        static void Main()
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            var sc = new Scan();
            int n, m, l;
            sc.Multi(out n, out m, out l);
            var a = new int[n][];
            var c = new int[m][];
            for (int i = 0; i < n; i++)
            {
                a[i] = sc.IntArr;
            }
            for (int i = 0; i < m; i++)
            {
                c[i] = sc.IntArr;
            }
            var dp = new long[m + 1][];
            for (int i = 0; i <= m; i++)
            {
                dp[i] = new long[l + 1];
            }
            for (int i = 0; i < m; i++)
            {
                for (int j = 0; j <= l; j++)
                {
                    if (c[i][0] > j)
                        dp[i + 1][j] = dp[i][j];
                    else
                        dp[i + 1][j] = Math.Max(dp[i][j], dp[i][j - c[i][0]] + c[i][1]);
 
                }
            }
            long max = 0;
            for (int i = 0; i < n; i++)
            {
                if (a[i][0] <= l)
                    max = Math.Max(max, dp[m][l - a[i][0]] + a[i][1]);
            }
            sw.WriteLine(max);
            sw.Flush();
        }
    }
    class Scan
    {
        public int Int { get { return int.Parse(Console.ReadLine().Trim()); } }
        public long Long { get { return long.Parse(Console.ReadLine().Trim()); } }
        public string Str { get { return Console.ReadLine().Trim(); } }
        public int[] IntArr { get { return Console.ReadLine().Trim().Split().Select(int.Parse).ToArray(); } }
        public int[] IntArrWithSep(char sep) { return Console.ReadLine().Trim().Split(sep).Select(int.Parse).ToArray(); }
        public long[] LongArr { get { return Console.ReadLine().Trim().Split().Select(long.Parse).ToArray(); } }
        public double[] DoubleArr { get { return Console.ReadLine().Split().Select(double.Parse).ToArray(); } }
        public string[] StrArr { get { return Console.ReadLine().Trim().Split(); } }
        public List<int> IntList { get { return Console.ReadLine().Trim().Split().Select(int.Parse).ToList(); } }
        public List<long> LongList { get { return Console.ReadLine().Trim().Split().Select(long.Parse).ToList(); } }
        public void Multi(out int a, out int b) { var arr = IntArr; a = arr[0]; b = arr[1]; }
        public void Multi(out int a, out int b, out int c) { var arr = IntArr; a = arr[0]; b = arr[1]; c = arr[2]; }
        public void Multi(out int a, out int b, out int c, out int d) { var arr = IntArr; a = arr[0]; b = arr[1]; c = arr[2]; d = arr[3]; }
        public void Multi(out int a, out string b) { var arr = StrArr; a = int.Parse(arr[0]); b = arr[1]; }
        public void Multi(out int a, out int b, out string c) { var arr = StrArr; a = int.Parse(arr[0]); b = int.Parse(arr[1]); c = arr[2]; }
        public void Multi(out int a, out char b) { var arr = StrArr; a = int.Parse(arr[0]); b = arr[1][0]; }
        public void Multi(out char a, out int b) { var arr = StrArr; a = arr[0][0]; b = int.Parse(arr[1]); }
        public void Multi(out long a, out long b) { var arr = LongArr; a = arr[0]; b = arr[1]; }
        public void Multi(out long a, out int b) { var arr = LongArr; a = arr[0]; b = (int)arr[1]; }
        public void Multi(out string a, out string b) { var arr = StrArr; a = arr[0]; b = arr[1]; }
    }
    class mymath
    {
        int M;
        const double eps = 1e-9;
        public mymath(int M) { this.M = M; }
        public long pow(long a, long b)
        {
            if (b == 0) return 1;
            if (b == 1) return a % M;
 
            long t = pow(a, b / 2);
 
            if ((b & 1) == 0) return t * t % M;
            else return t * t % M * a % M;
        }
        public long gcd(long a, long b)
        {
            while (b != 0)
            {
                var t = a % b;
                a = b;
                b = t;
            }
            return a;
        }
        public long lcm(int a, int b) { return (a * b) / gcd(a, b); }
    }
}

Submission Info

Submission Time
Task G - 主菜と副菜
User riantkb
Language C# (Mono 3.2.1.0)
Score 100
Code Size 4447 Byte
Status AC
Exec Time 569 ms
Memory 95016 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 43
Set Name Test Cases
Sample 0-sample-1, 0-sample-2, 0-sample-3
All 0-sample-1, 0-sample-2, 0-sample-3, 1-random-00, 1-random-01, 1-random-02, 1-random-03, 1-random-04, 1-random-05, 1-random-06, 1-random-07, 1-random-08, 1-random-09, 1-random-10, 1-random-11, 1-random-12, 1-random-13, 1-random-14, 1-random-15, 1-random-16, 1-random-17, 1-random-18, 1-random-19, 1-random-20, 1-random-21, 1-random-22, 1-random-23, 1-random-24, 1-random-25, 1-random-26, 1-random-27, 1-random-28, 1-random-29, 2-max-0, 2-max-1, 2-max-2, 2-max-3, 2-max-4, 2-max-5, 2-max-6, 2-max-7, 2-max-8, 2-max-9
Case Name Status Exec Time Memory
0-sample-1 AC 200 ms 9892 KB
0-sample-2 AC 129 ms 9892 KB
0-sample-3 AC 143 ms 9888 KB
1-random-00 AC 229 ms 40344 KB
1-random-01 AC 193 ms 28080 KB
1-random-02 AC 155 ms 13860 KB
1-random-03 AC 154 ms 15172 KB
1-random-04 AC 351 ms 71892 KB
1-random-05 AC 212 ms 35992 KB
1-random-06 AC 198 ms 28816 KB
1-random-07 AC 394 ms 88628 KB
1-random-08 AC 261 ms 41744 KB
1-random-09 AC 260 ms 42140 KB
1-random-10 AC 275 ms 26480 KB
1-random-11 AC 342 ms 49016 KB
1-random-12 AC 361 ms 49784 KB
1-random-13 AC 239 ms 32280 KB
1-random-14 AC 297 ms 47268 KB
1-random-15 AC 144 ms 13756 KB
1-random-16 AC 377 ms 76244 KB
1-random-17 AC 196 ms 30920 KB
1-random-18 AC 143 ms 12188 KB
1-random-19 AC 139 ms 13048 KB
1-random-20 AC 195 ms 15284 KB
1-random-21 AC 376 ms 82712 KB
1-random-22 AC 426 ms 55416 KB
1-random-23 AC 310 ms 62428 KB
1-random-24 AC 337 ms 15772 KB
1-random-25 AC 298 ms 62852 KB
1-random-26 AC 162 ms 20156 KB
1-random-27 AC 286 ms 57084 KB
1-random-28 AC 323 ms 69852 KB
1-random-29 AC 255 ms 38044 KB
2-max-0 AC 528 ms 95004 KB
2-max-1 AC 569 ms 95000 KB
2-max-2 AC 407 ms 95004 KB
2-max-3 AC 490 ms 95016 KB
2-max-4 AC 504 ms 95004 KB
2-max-5 AC 512 ms 94996 KB
2-max-6 AC 406 ms 95000 KB
2-max-7 AC 514 ms 94996 KB
2-max-8 AC 406 ms 95000 KB
2-max-9 AC 410 ms 95004 KB