結果
| 問題 |
No.505 カードの数式2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-04-21 22:54:51 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
MLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 615 bytes |
| コンパイル時間 | 812 ms |
| コンパイル使用メモリ | 118,316 KB |
| 実行使用メモリ | 546,496 KB |
| 最終ジャッジ日時 | 2024-06-12 18:48:59 |
| 合計ジャッジ時間 | 6,316 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 MLE * 1 -- * 3 |
ソースコード
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);
auto dp = new long[long][](N);
dp[0][A[0]] = true;
foreach (i; 0..N-1) {
foreach (j; dp[i].keys) {
dp[i+1][j+A[i+1]] = true;
dp[i+1][j-A[i+1]] = true;
dp[i+1][j*A[i+1]] = true;
if (A[i+1] != 0) dp[i+1][j/A[i+1]] = true;
}
}
writeln(dp[N-1].keys.reduce!max);
}