結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー りあんりあん
提出日時 2019-12-05 23:00:06
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 259 ms / 2,500 ms
コード長 3,361 bytes
コンパイル時間 5,370 ms
コンパイル使用メモリ 110,144 KB
実行使用メモリ 61,768 KB
最終ジャッジ日時 2023-09-06 07:50:21
合計ジャッジ時間 10,071 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
21,592 KB
testcase_01 AC 68 ms
19,608 KB
testcase_02 AC 64 ms
21,712 KB
testcase_03 AC 64 ms
21,788 KB
testcase_04 AC 67 ms
21,584 KB
testcase_05 AC 67 ms
21,760 KB
testcase_06 AC 67 ms
21,592 KB
testcase_07 AC 68 ms
23,700 KB
testcase_08 AC 74 ms
23,956 KB
testcase_09 AC 77 ms
21,876 KB
testcase_10 AC 79 ms
21,848 KB
testcase_11 AC 207 ms
54,012 KB
testcase_12 AC 214 ms
52,192 KB
testcase_13 AC 198 ms
54,352 KB
testcase_14 AC 87 ms
23,872 KB
testcase_15 AC 147 ms
48,736 KB
testcase_16 AC 200 ms
60,032 KB
testcase_17 AC 101 ms
30,748 KB
testcase_18 AC 234 ms
58,888 KB
testcase_19 AC 163 ms
54,076 KB
testcase_20 AC 98 ms
32,344 KB
testcase_21 AC 79 ms
23,956 KB
testcase_22 AC 89 ms
32,684 KB
testcase_23 AC 76 ms
21,764 KB
testcase_24 AC 154 ms
49,588 KB
testcase_25 AC 258 ms
59,720 KB
testcase_26 AC 259 ms
61,672 KB
testcase_27 AC 215 ms
61,768 KB
testcase_28 AC 248 ms
57,576 KB
testcase_29 AC 204 ms
61,736 KB
testcase_30 AC 161 ms
59,716 KB
testcase_31 AC 144 ms
59,620 KB
testcase_32 AC 228 ms
59,848 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using static util;

class Program {
    static void Main(string[] args) {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        var solver = new Solver(sw);
        // var t = new Thread(solver.solve, 1 << 26); // 64 MB
        // t.Start();
        // t.Join();
        solver.solve();
        sw.Flush();
    }
}

class Solver {
    StreamWriter sw;
    Scan sc;
    void Prt(string a) => sw.WriteLine(a);
    void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
    void Prt(params object[] a) => Prt(string.Join(" ", a));
    public Solver(StreamWriter sw) {
        this.sw = sw;
        this.sc = new Scan();
    }

    public void solve() {
        int n = sc.Int;
        var a = sc.IntArr;
        var b = sc.IntArr;
        var d = sc.IntArr;
        Array.Sort(d);
        var dp = new int[n + 1][];
        for (int i = 0; i < n + 1; i++)
            dp[i] = new int[n + 1];

        dp[0][0] = M;
        int ans = 0;
        for (int i = 0; i < n + 1; i++)
        {
            int k = n;
            for (int j = 0; i + j < n + 1; j++)
            {
                while (k > 0 && d[k - 1] > a[i] + b[j]) --k;
                if (i == 0 && j == 0) continue;

                int ma = -1;
                if (i > 0) ma = Math.Max(ma, dp[i - 1][j] - 1);
                if (j > 0) ma = Math.Max(ma, dp[i][j - 1] - 1);
                dp[i][j] = Math.Min(k, ma);

                if (dp[i][j] > 0)
                    ans = Math.Max(ans, i + j);
                else break;
            }
        }
        Prt(ans);
    }
}

static class util {
    public static readonly int M = 1000000007;
    // public static readonly int M = 998244353;
}

class Scan {
    StreamReader sr;
    public Scan() { sr = new StreamReader(Console.OpenStandardInput()); }
    public Scan(string path) { sr = new StreamReader(path); }
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public string Str => sr.ReadLine().Trim();
    public int[] IntArr => StrArr.Select(int.Parse).ToArray();
    public long[] LongArr => StrArr.Select(long.Parse).ToArray();
    public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();
    public string[] StrArr => Str.Split(new[]{' '}, StringSplitOptions.RemoveEmptyEntries);
    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);
    public void Multi<T>(out T a) => a = cv<T>(Str);
    public void Multi<T, U>(out T a, out U b)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); }
    public void Multi<T, U, V>(out T a, out U b, out V c)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); }
    public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); }
}
0