結果
| 問題 |
No.3017 交互浴
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-25 18:59:10 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 879 bytes |
| コンパイル時間 | 12,600 ms |
| コンパイル使用メモリ | 402,064 KB |
| 実行使用メモリ | 7,168 KB |
| 最終ジャッジ日時 | 2025-01-26 00:03:03 |
| 合計ジャッジ時間 | 29,884 ms |
|
ジャッジサーバーID (参考情報) |
judge13 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 15 WA * 40 |
ソースコード
use proconio::input;
fn main() {
input! {
n: usize,
h: [i64; n],
}
let mut stack = vec![];
let mut water = 0;
let mut green = 0;
for (i, &h_i) in h.iter().enumerate() {
while let Some(&(top_h, top_c)) = stack.last() {
if top_h > h_i {
break;
}
stack.pop();
if top_c == 0 {
water -= top_h;
} else {
green -= top_h;
}
}
if let Some(&(_, top_c)) = stack.last() {
if top_c == i % 2 {
println!("{}", (water - green).max(0));
continue;
}
}
stack.push((h_i, i % 2));
if i % 2 == 0 {
water += h_i;
} else {
green += h_i;
}
println!("{}", (water - green).max(0));
}
}