結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー nebukuro09
提出日時 2019-12-12 01:49:29
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 863 bytes
コンパイル時間 806 ms
コンパイル使用メモリ 123,160 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-22 03:30:46
合計ジャッジ時間 1,812 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;
    auto B = readln.split.map!(to!long).array;
    auto D = readln.split.map!(to!long).array;
    D.sort!"a > b";

    auto C = new long[](N);

    for (int i = 0, j = 0, k = -1; k < N; ++k) {
        if (i + j > 0) C[k] = A[i] + B[j];
        if (i == N) ++j;
        else if (j == N) ++i;
        else if (A[i] + B[j+1] >= A[i+1] + B[j]) ++j;
        else ++i;
    }

    int ans = 0;

    for (int i = 0, j = 0; i < N && j < N; ) {
        if (C[i] >= D[j]) {
            ++ans;
            ++i;
            ++j;
        } else {
            ++j;
        }
    }

    ans.writeln;
}


0