結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー りあんりあん
提出日時 2019-12-06 06:38:42
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 431 ms / 2,500 ms
コード長 3,098 bytes
コンパイル時間 2,549 ms
コンパイル使用メモリ 111,448 KB
実行使用メモリ 28,204 KB
最終ジャッジ日時 2023-09-06 07:53:02
合計ジャッジ時間 9,728 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
19,728 KB
testcase_01 AC 66 ms
21,748 KB
testcase_02 AC 64 ms
21,828 KB
testcase_03 AC 64 ms
21,848 KB
testcase_04 AC 66 ms
21,664 KB
testcase_05 AC 66 ms
23,700 KB
testcase_06 AC 65 ms
19,824 KB
testcase_07 AC 67 ms
21,780 KB
testcase_08 AC 75 ms
21,860 KB
testcase_09 AC 74 ms
21,988 KB
testcase_10 AC 76 ms
21,980 KB
testcase_11 AC 276 ms
24,044 KB
testcase_12 AC 301 ms
25,928 KB
testcase_13 AC 256 ms
28,108 KB
testcase_14 AC 99 ms
23,768 KB
testcase_15 AC 198 ms
28,024 KB
testcase_16 AC 327 ms
28,052 KB
testcase_17 AC 108 ms
26,112 KB
testcase_18 AC 407 ms
28,116 KB
testcase_19 AC 190 ms
26,060 KB
testcase_20 AC 96 ms
21,960 KB
testcase_21 AC 76 ms
23,864 KB
testcase_22 AC 78 ms
22,048 KB
testcase_23 AC 73 ms
23,908 KB
testcase_24 AC 239 ms
25,960 KB
testcase_25 AC 393 ms
24,080 KB
testcase_26 AC 431 ms
26,088 KB
testcase_27 AC 364 ms
26,108 KB
testcase_28 AC 423 ms
28,204 KB
testcase_29 AC 244 ms
28,192 KB
testcase_30 AC 119 ms
26,132 KB
testcase_31 AC 81 ms
22,268 KB
testcase_32 AC 346 ms
28,108 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);
        int ok = 0, ng = n + 1;
        while (ng - ok > 1) {
            int m = (ok + ng) / 2;
            var f = new bool[1];
            f[0] = true;
            for (int i = 1; i <= m; i++)
            {
                var nf = new bool[i + 1];
                for (int j = 0; j <= i; j++)
                    nf[j] = a[j] + b[i - j] >= d[m - i] && (j < i && f[j] || j > 0 && f[j - 1]);

                f = nf;
            }
            if (f.Any(x => x))
                ok = m;
            else ng = m;
        }
        Prt(ok);
    }
}

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

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