結果

問題 No.1238 選抜クラス
ユーザー g4np0n_kyoprog4np0n_kyopro
提出日時 2020-09-25 23:14:32
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 1,664 ms / 2,000 ms
コード長 8,104 bytes
コンパイル時間 2,706 ms
コンパイル使用メモリ 66,796 KB
実行使用メモリ 31,448 KB
最終ジャッジ日時 2023-09-10 16:16:40
合計ジャッジ時間 29,342 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
21,792 KB
testcase_01 AC 63 ms
21,864 KB
testcase_02 AC 63 ms
21,776 KB
testcase_03 AC 62 ms
21,756 KB
testcase_04 AC 62 ms
21,812 KB
testcase_05 AC 61 ms
21,764 KB
testcase_06 AC 62 ms
21,848 KB
testcase_07 AC 61 ms
21,708 KB
testcase_08 AC 64 ms
21,592 KB
testcase_09 AC 66 ms
21,772 KB
testcase_10 AC 62 ms
21,764 KB
testcase_11 AC 66 ms
21,816 KB
testcase_12 AC 63 ms
21,708 KB
testcase_13 AC 63 ms
21,828 KB
testcase_14 AC 63 ms
21,788 KB
testcase_15 AC 68 ms
21,880 KB
testcase_16 AC 66 ms
21,808 KB
testcase_17 AC 1,649 ms
29,444 KB
testcase_18 AC 1,512 ms
28,708 KB
testcase_19 AC 1,566 ms
29,264 KB
testcase_20 AC 1,430 ms
30,684 KB
testcase_21 AC 1,299 ms
30,128 KB
testcase_22 AC 1,664 ms
31,444 KB
testcase_23 AC 1,658 ms
29,428 KB
testcase_24 AC 1,654 ms
29,576 KB
testcase_25 AC 1,640 ms
31,448 KB
testcase_26 AC 1,655 ms
31,384 KB
testcase_27 AC 1,650 ms
29,340 KB
testcase_28 AC 1,659 ms
29,392 KB
testcase_29 AC 1,555 ms
27,208 KB
testcase_30 AC 106 ms
23,992 KB
testcase_31 AC 326 ms
23,792 KB
testcase_32 AC 782 ms
26,376 KB
testcase_33 AC 61 ms
19,592 KB
testcase_34 AC 1,035 ms
29,180 KB
testcase_35 AC 151 ms
20,552 KB
testcase_36 AC 72 ms
21,724 KB
testcase_37 AC 115 ms
24,304 KB
testcase_38 AC 1,418 ms
28,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;

public static class Ex
{
    public static bool IsNullOrEmpty(this string s) { return string.IsNullOrEmpty(s); }
    public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.OrdinalIgnoreCase); return s.ToList(); }
    public static void yesno(this bool b) { Console.WriteLine(b ? "yes" : "no"); }
    public static void YesNo(this bool b) { Console.WriteLine(b ? "Yes" : "No"); }
    public static void YESNO(this bool b) { Console.WriteLine(b ? "YES" : "NO"); }
    public static int PopCount(this uint bits)
    {
        bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
        bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
        bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
        bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
        return (int)((bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff));
    }
}



partial class Program
{
    string GetStr() { return Console.ReadLine().Trim(); }
    char GetChar() { return Console.ReadLine().Trim()[0]; }
    int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
    long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
    double GetDouble() { return double.Parse(Console.ReadLine().Trim()); }
    string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); }
    string[][] GetStrArray(int N)
    {
        var res = new string[N][];
        for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ');
        return res;
    }
    int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); }
    int[][] GetIntArray(int N)
    {
        var res = new int[N][];
        for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
        return res;
    }
    public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); }
    long[][] GetLongArray(int N)
    {
        var res = new long[N][];
        for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
        return res;
    }
    char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); }
    double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); }
    double[][] GetDoubleArray(int N)
    {
        var res = new double[N][];
        for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
        return res;
    }
    char[][] GetGrid(int H)
    {
        var res = new char[H][];
        for (int i = 0; i < H; i++) res[i] = Console.ReadLine().Trim().ToCharArray();
        return res;
    }
    T[] CreateArray<T>(int N, T value)
    {
        var res = new T[N];
        for (int i = 0; i < N; i++) res[i] = value;
        return res;
    }
    T[][] CreateArray<T>(int H, int W, T value)
    {
        var res = new T[H][];
        for (int i = 0; i < H; i++)
        {
            res[i] = new T[W];
            for (int j = 0; j < W; j++) res[i][j] = value;
        }
        return res;
    }
    T[][][] CreateArray<T>(int H, int W, int R, T value)
    {
        var res = new T[H][][];
        for (int i = 0; i < H; i++)
        {
            res[i] = new T[W][];
            for (int j = 0; j < W; j++)
            {
                res[i][j] = new T[R];
                for (int k = 0; k < R; k++) res[i][j][k] = value;
            }
        }
        return res;
    }

    Dictionary<int, List<int>> GetUnweightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed)
    {
        var dic = new Dictionary<int, List<int>>();
        foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<int>()); }
        for (int i = 0; i < M; i++)
        {
            var input = GetIntArray();
            var a = isNode_0indexed ? input[0] : input[0] - 1;
            var b = isNode_0indexed ? input[1] : input[1] - 1;
            dic[a].Add(b);
            if (isDirected == false) dic[b].Add(a);
        }
        return dic;
    }
    //Dictionary<int, List<(int node, long cost)>> GetWeightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed)
    //{
    //    var dic = new Dictionary<int, List<(int, long)>>();
    //    foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<(int, long)>()); }
    //    for (int i = 0; i < M; i++)
    //    {
    //        var input = GetIntArray();
    //        var a = isNode_0indexed ? input[0] : input[0] - 1;
    //        var b = isNode_0indexed ? input[1] : input[1] - 1;
    //        var c = input[2];
    //        dic[a].Add((b, c));
    //        if (isDirected == false) dic[b].Add((a, c));
    //    }
    //    return dic;
    //}

    bool eq<T, U>() => typeof(T).Equals(typeof(U));
    T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
    T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                       : eq<T, long>() ? ct<T, long>(long.Parse(s))
                       : eq<T, double>() ? ct<T, double>(double.Parse(s))
                       : eq<T, char>() ? ct<T, char>(s[0])
                                         : ct<T, string>(s);
    void Multi<T>(out T a) => a = cv<T>(GetStr());
    void Multi<T, U>(out T a, out U b)
    {
        var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
    }
    void Multi<T, U, V>(out T a, out U b, out V c)
    {
        var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
    }
    void Multi<T, U, V, W>(out T a, out U b, out V c, out W d)
    {
        var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
    }
    void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e)
    {
        var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]);
    }
    void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f)
    {
        var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]);
    }

    void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }

    int[] dx = new int[] { 1, 0, -1, 0, 1, 1, -1, -1 };
    int[] dy = new int[] { 0, 1, 0, -1, 1, -1, 1, -1 };
    long mod = 1000000007;
}

class Pair : IComparable<Pair>
{
    public Pair(int _node, long _cost)
    {
        node = _node; cost = _cost;
    }
    public int node;
    public long cost;
    public int CompareTo(Pair p)
    {
        return p.cost > cost ? 1 : -1;
    }
}

class Comparable : IComparable<Comparable>
{
    public Comparable(int x, int id)
    {
        X = x;
        Id = id;
    }

    public int X;
    public int Id;
    public int CompareTo(Comparable c)
    {
        return X >= c.X ? -1 : 1;
    }
}

class Comparer<T> : IComparer<T>
{
    public int Compare(T t1, T t2)
    {
        return 1;
    }
}





partial class Program
{
    static void Main()
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Console.Out.Flush();
        Console.Read();
    }

    public void Solve()
    {
        int N, K;
        Multi(out N, out K);
        var A = GetIntArray();
        var dp = CreateArray(N + 1, N * 100 + 1, 0L);
        dp[0][0] = 1;
        for (int i = 0; i < N; i++)
        {
            for (int j = N - 1; j >= 0; j--)
            {
                for (int k = N * 100; k >= A[i]; k--)
                {
                    dp[j + 1][k] = (dp[j + 1][k] + dp[j][k - A[i]])% mod;
                }
            }
        }

        long cnt = 0;
        for (int j = 1; j <= N; j++)
        {
            for (int k = j * K; k <= N * 100; k++)
            {
                cnt = (cnt + dp[j][k]) % mod;
            }
        }
        Console.WriteLine(cnt);
    }

}
0