結果
問題 |
No.1435 Mmm......
|
ユーザー |
![]() |
提出日時 | 2021-03-19 22:54:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 925 bytes |
コンパイル時間 | 1,833 ms |
コンパイル使用メモリ | 171,812 KB |
実行使用メモリ | 13,440 KB |
最終ジャッジ日時 | 2024-11-19 00:22:35 |
合計ジャッジ時間 | 4,470 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 WA * 2 |
ソースコード
#include<bits/stdc++.h> template<class T> inline bool chmax(T& a, T b){ if (a < b){ a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b){ if (a > b){ a = b; return true; } return false; } using namespace std; using ll = long long; ll mod = 1e9+7; int main(){ int n; cin >> n; vector<int> a(n); for(int i=0; i<n; ++i) cin >> a[i]; multiset<int> st; int ans = 0; int l = 0; for (int r=0; r<n; ++r) { st.insert(a[r]); bool ok = false; while (true) { if (st.size() < 2) break; int m1 = *st.begin(); int m2 = *next(st.begin(), 1); int M = *st.rbegin(); if (m1 + m2 < M) { st.erase(st.find(a[l])); l++; continue; } ok = true; break; } ans += r - l; } cout << ans << endl; }