Submission #1517732


Source Code Expand

import std.stdio, std.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching;


void main(){
    auto n=readln.chomp.to!int;
    auto as=readln.chomp.split.map!(to!int).array;

    writeln(maxT(as));
}

int aoki(int[] arr, int t,int a){
    return arr[min(t,a)..max(t,a)+1].drop(1).stride(2).sum;
}

int takahasi(int[] arr, int t,int a){
    return arr[min(t,a)..max(t,a)+1].stride(2).sum;
}

int maxAIndex(int[] arr, int t){
    auto as=iota(0,arr.length).setDifference([t]);
    return as.maxElement!(a=>aoki(arr,t,a));
}

int maxT(int[] arr){
    auto ts=iota(0,arr.length);
    return ts.map!(t=>takahasi(arr,t,maxAIndex(arr, t))).maxElement();
}

Submission Info

Submission Time
Task C - 数列ゲーム
User faidra
Language D (DMD64 v2.070.1)
Score 0
Code Size 739 Byte
Status CE

Compile Error

./Main.d(21): Error: no property 'maxElement' for type 'SetDifference!("a < b", Result, int[])'
./Main.d(26): Error: function Main.maxAIndex (int[] arr, int t) is not callable using argument types (int[], ulong)
/usr/include/dmd/phobos/std/algorithm/iteration.d(473):        instantiated from here: MapResult!(__lambda2, Result)
./Main.d(26):        instantiated from here: map!(Result)
./Main.d(26): Error: no property 'maxElement' for type 'MapResult!(__lambda2, Result)'