結果
| 問題 | No.1435 Mmm...... |
| コンテスト | |
| ユーザー |
nok0
|
| 提出日時 | 2021-03-20 00:12:33 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 83 ms / 2,000 ms |
| コード長 | 480 bytes |
| 記録 | |
| コンパイル時間 | 708 ms |
| コンパイル使用メモリ | 94,956 KB |
| 実行使用メモリ | 14,080 KB |
| 最終ジャッジ日時 | 2026-06-18 22:10:04 |
| 合計ジャッジ時間 | 2,306 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 24 |
ソースコード
#include <iostream>
#include <set>
#include <vector>
long long res;
int n, a[200000];
std::multiset<int> st;
int main() {
scanf("%d", &n);
for(int i = 0; i < n; i++) scanf("%d", &a[i]);
for(int l = 0, r = 0; l < n; res += r - l - 1, st.erase(st.lower_bound((a[l++])))) {
while(r < n) {
st.insert(a[r]);
int tmp = *st.begin() + *(++st.begin()) - *st.rbegin();
if(tmp < 0) {
st.erase(st.lower_bound(a[r]));
break;
}
r++;
}
}
printf("%lld\n", res);
}
nok0