結果
問題 | No.2036 Max Middle |
ユーザー |
![]() |
提出日時 | 2022-08-12 21:55:58 |
言語 | Crystal (1.14.0) |
結果 |
AC
|
実行時間 | 33 ms / 2,000 ms |
コード長 | 282 bytes |
コンパイル時間 | 13,359 ms |
コンパイル使用メモリ | 294,968 KB |
実行使用メモリ | 18,764 KB |
最終ジャッジ日時 | 2024-09-23 02:24:03 |
合計ジャッジ時間 | 14,911 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 |
ソースコード
n = read_line.to_i a = read_line.split.map(&.to_i) last = 0i64 1.upto(n - 1) do |i| last += a[i - 1] < a[i] ? 1 : -1 end ans = 0i64 cur = 0i64 1.upto(n - 1) do |i| cur += a[i - 1] < a[i] ? 1 : -1 bottom = {-i, last - (n - 1 - i)}.max ans += (cur - bottom) // 2 end puts ans