結果
| 問題 |
No.2854 -1 Subsequence
|
| コンテスト | |
| ユーザー |
SnowBeenDiding
|
| 提出日時 | 2024-08-25 13:49:55 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 662 bytes |
| コンパイル時間 | 2,641 ms |
| コンパイル使用メモリ | 249,500 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-08-25 13:50:02 |
| 合計ジャッジ時間 | 5,665 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 8 WA * 32 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
using namespace std;
typedef long long ll;
template <typename T, typename S> bool chmin(T &a, S b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i, 0, n) cin >> a[i];
n += 3;
a.insert(a.begin(), 2e9);
a.push_back(0);
a.push_back(0);
int nw = a[0];
ll ans = 0;
rep(i, 1, n - 1) {
if (a[i - 1] < a[i] && a[i] > a[i + 1]) {
ans += a[i] - nw;
nw = a[i];
}
chmin(nw, a[i]);
}
cout << ans << endl;
}
SnowBeenDiding