結果
問題 |
No.10 +か×か
|
ユーザー |
|
提出日時 | 2016-11-04 22:07:17 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 800 bytes |
コンパイル時間 | 947 ms |
コンパイル使用メモリ | 108,288 KB |
実行使用メモリ | 7,296 KB |
最終ジャッジ日時 | 2024-06-12 04:57:46 |
合計ジャッジ時間 | 1,619 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 WA * 5 |
ソースコード
import std.stdio; import std.array; import std.string; import std.conv; import std.algorithm; import std.typecons; import std.range; import std.random; import std.math; import std.container; void main() { auto N = readln.chomp.to!int; auto T = readln.chomp.to!int; auto A = readln.split.map!(to!int).array; auto dp = new char[][](N, T+1); dp[0][A[0]] = '+'; foreach (i; iota(N-1)) foreach (j; iota(T+1)) { if (dp[i][j] != char.init) { if (j * A[i+1] <= T && dp[i+1][j*A[i+1]] == 0xFF) dp[i+1][j*A[i+1]] = '*'; if (j + A[i+1] <= T) dp[i+1][j+A[i+1]] = '+'; } } string ans = ""; foreach (i; iota(N-1, 0, -1)) { ans = dp[i][T] ~ ans; if (dp[i][T] == '*') T /= A[i]; else T -= A[i]; } writeln(ans); }