結果

問題 No.45 回転寿司
ユーザー kiridaruma
提出日時 2016-05-15 11:27:57
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 641 bytes
コンパイル時間 783 ms
コンパイル使用メモリ 101,120 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-12 03:30:01
合計ジャッジ時間 1,727 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 1 WA * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.string, std.conv;
import std.array, std.algorithm;

void main(){
    auto l = readln.strip.to!int;
    auto arr = readln.strip.split.map!(to!int).array;
    uint ans;
    if(l == 1){ans = arr[0];}
    while(arr.length > 1){
        int max, pos;
        foreach(i, x; arr){
            if(max < x){
                max = x;
                pos = i.to!int;
            }
        }
        ans += max;
        
        if(pos+1 < arr.length){
            arr = arr.remove(pos+1);
        }
        arr = arr.remove(pos);
        if(pos-1 >= 0){
            arr = arr.remove(pos-1);
        }
    }
    
    ans.writeln;
}
0