結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2018-12-06 00:01:15 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 557 bytes |
コンパイル時間 | 885 ms |
コンパイル使用メモリ | 127,112 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-13 02:01:19 |
合計ジャッジ時間 | 1,771 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
import std.stdio, std.conv, std.string, std.bigint; import std.math, std.random, std.datetime; import std.array, std.range, std.algorithm, std.container; string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; } void main(){ int n = read.to!int; int[] vs = readln.chomp.split.map!(to!int).array; int a, b; a = vs[0], b = 0; for(int i = 1; i < n; i ++){ int a2, b2; if(a > b) b2 = a; else b2 = b; a2 = b + vs[i]; a = a2, b = b2; } if(a > b) a.writeln; else b.writeln; }