Submission #14737776


Source Code Expand

// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long N, M, K;
    scan(N, M, K);
    auto A = aryread();
    auto B = aryread();
    auto S = [0L] ~ B ~ [0L];
    foreach (i; 0 .. M)
    {
        S[i + 1] += S[i];
    }
    long as;
    long ans;
    foreach (i; 0 .. N + 1)
    {
        long ok = 0;
        long ng = M + 1;
        while (1 < (ng - ok))
        {
            long j = (ok + ng) / 2;
            if (S[j] <= K - as)
            {
                ok = j;
            }
            else
            {
                ng = j;
            }
        }
        dprint(i, ok);
        if (as + S[ok] <= K)
            ans = ans.max(i + ok);
        if (i < A.length)
            as += A[i];
    }
    writeln(ans);
}

Submission Info

Submission Time
Task C - Tsundoku
User kotet
Language D (DMD 2.091.0)
Score 300
Code Size 1302 Byte
Status AC
Exec Time 99 ms
Memory 22936 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 20
Set Name Test Cases
Sample a01.txt, a02.txt, a03.txt
All a01.txt, a02.txt, a03.txt, b04.txt, b05.txt, b06.txt, b07.txt, b08.txt, b09.txt, b10.txt, b11.txt, b12.txt, b13.txt, b14.txt, b15.txt, b16.txt, b17.txt, b18.txt, b19.txt, b20.txt
Case Name Status Exec Time Memory
a01.txt AC 10 ms 3572 KiB
a02.txt AC 2 ms 3592 KiB
a03.txt AC 2 ms 3528 KiB
b04.txt AC 2 ms 3568 KiB
b05.txt AC 99 ms 22936 KiB
b06.txt AC 66 ms 15112 KiB
b07.txt AC 3 ms 3528 KiB
b08.txt AC 75 ms 15208 KiB
b09.txt AC 35 ms 11020 KiB
b10.txt AC 40 ms 9260 KiB
b11.txt AC 44 ms 13956 KiB
b12.txt AC 63 ms 12960 KiB
b13.txt AC 73 ms 13628 KiB
b14.txt AC 78 ms 14904 KiB
b15.txt AC 73 ms 13952 KiB
b16.txt AC 75 ms 13608 KiB
b17.txt AC 76 ms 13756 KiB
b18.txt AC 78 ms 14080 KiB
b19.txt AC 74 ms 14272 KiB
b20.txt AC 55 ms 13940 KiB