結果
問題 | No.2036 Max Middle |
ユーザー | kuroni |
提出日時 | 2022-08-12 21:28:08 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 683 bytes |
コンパイル時間 | 1,551 ms |
コンパイル使用メモリ | 168,548 KB |
実行使用メモリ | 4,348 KB |
最終ジャッジ日時 | 2023-10-24 08:11:35 |
合計ジャッジ時間 | 2,956 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,348 KB |
testcase_01 | AC | 2 ms
4,348 KB |
testcase_02 | AC | 2 ms
4,348 KB |
testcase_03 | AC | 2 ms
4,348 KB |
testcase_04 | AC | 2 ms
4,348 KB |
testcase_05 | AC | 2 ms
4,348 KB |
testcase_06 | AC | 2 ms
4,348 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 22 ms
4,348 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } int ans = 0; for (int j = 0; j < 3; j++) { for (int i = 1; i < n - 1; i++) { if (a[i] > max(a[i - 1], a[i + 1])) { a[i] = min(a[i - 1], a[ i + 1]) - 1; ans++; } } for (int i = n - 2; i > 0; i--) { if (a[i] > max(a[i - 1], a[i + 1])) { a[i] = min(a[i - 1], a[i + 1]) - 1; ans++; } } } cout << ans; }