結果
| 問題 |
No.1435 Mmm......
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-22 22:05:21 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 148 ms / 2,000 ms |
| コード長 | 849 bytes |
| コンパイル時間 | 1,071 ms |
| コンパイル使用メモリ | 96,740 KB |
| 実行使用メモリ | 13,440 KB |
| 最終ジャッジ日時 | 2024-11-24 10:22:53 |
| 合計ジャッジ時間 | 4,572 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 24 |
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int a[200020];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
multiset<int> st;
st.insert(a[0]);
st.insert(a[1]);
int r = 1;
long long ans = 0;
for (int l = 0; l < n - 1; l++) {
int m1 = *st.begin() + *(++st.begin());
int m = *st.rbegin();
while (r < n && m1 >= m) {
r++;
if (r == n)break;
st.insert(a[r]);
m1 = *st.begin() + *(++st.begin());
m = *st.rbegin();
}
ans += r - l - 1;
if (l == r) {
r++;
st.insert(a[r]);
}
else {
st.erase(st.find(a[l]));
}
}
cout << ans << endl;
}