結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-13 16:14:03 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 829 bytes |
| コンパイル時間 | 13,001 ms |
| コンパイル使用メモリ | 405,240 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-13 16:14:22 |
| 合計ジャッジ時間 | 16,010 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 8 OLE * 4 |
ソースコード
use proconio::input;
fn main() {
input! {
n: usize,
tot: usize,
a: [usize; n]
}
let mut dp = vec![vec![false; tot + 1]; n + 1];
dp[n][tot] = true;
for i in (0..n).rev() {
for j in 0..=tot {
if j + a[i] <= tot && dp[i + 1][j + a[i]] {
dp[i][j] = true;
}
if j * a[i] <= tot && dp[i + 1][j * a[i]] {
dp[i][j] = true;
}
}
}
for i in 0..=n {
println!("{:?}", dp[i]);
}
let mut cur = a[0];
let mut ans: String = String::new();
for i in 1..n {
if cur + a[i] <= tot && dp[i + 1][cur + a[i]] {
cur += a[i];
ans.push('+');
}else {
cur *= a[i];
ans.push('*');
}
}
println!("{}", ans);
}