結果
| 問題 | No.1435 Mmm...... |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-20 10:29:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 703 ms / 2,000 ms |
| コード長 | 1,409 bytes |
| 記録 | |
| コンパイル時間 | 4,205 ms |
| コンパイル使用メモリ | 232,184 KB |
| 実行使用メモリ | 20,324 KB |
| 最終ジャッジ日時 | 2024-11-20 19:27:30 |
| 合計ジャッジ時間 | 13,436 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 24 |
ソースコード
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define itr(x,c) for(auto x=c.begin();x!=c.end();x++)
#define ritr(x,c) for(auto x=c.rbegin();x!=c.rend();x++)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define __builtin_popcount(v) popcount(v)
using namespace std;
#include <atcoder/all>
using namespace atcoder;
typedef long long ll;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
//static const ll MOD=998244353;
//for(i=0;i<N;i++) cin>>a[i];
typedef vector<ll> v1d;
typedef vector<v1d> v2d;
typedef vector<v2d> v3d;
typedef vector<v3d> v4d;
struct S{ll M, m1, m2;};
S op(S a, S b){
ll M=max(a.M,b.M);
ll m1=min(a.m1,b.m1);
ll m2=a.m1<b.m1?min({b.m1,a.m2,b.m2}):min({a.m1,a.m2,b.m2});
return {M,m1,m2};
}
S e(){return {-INF,INF,INF};}
int main(void) {
ll i,j,k;
ll N;cin>>N;
segtree<S,op,e> seg(N);
for(i=0;i<N;i++){
ll a;cin>>a;
seg.set(i,{a,a,INF});
}
ll ans=0;
for(i=0;i<N-1;i++){
ll l=i+1,r=N;
while(l+1<r){
ll m=(l+r)/2;
S v=seg.prod(i,m+1);
ll M=v.M,m1=v.m1,m2=v.m2;
M<=m1+m2?l=m:r=m;
}
ans+=l-i;
}
pt(ans);
}