結果

問題 No.1435 Mmm......
ユーザー eQeeQe
提出日時 2021-03-20 10:47:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 1,318 bytes
コンパイル時間 3,378 ms
コンパイル使用メモリ 233,116 KB
実行使用メモリ 20,312 KB
最終ジャッジ日時 2024-04-30 21:42:43
合計ジャッジ時間 6,446 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 65 ms
18,804 KB
testcase_07 AC 77 ms
19,480 KB
testcase_08 AC 89 ms
20,048 KB
testcase_09 AC 81 ms
19,676 KB
testcase_10 AC 72 ms
19,144 KB
testcase_11 AC 71 ms
18,936 KB
testcase_12 AC 67 ms
18,928 KB
testcase_13 AC 65 ms
18,648 KB
testcase_14 AC 48 ms
11,744 KB
testcase_15 AC 90 ms
20,272 KB
testcase_16 AC 76 ms
19,404 KB
testcase_17 AC 53 ms
12,144 KB
testcase_18 AC 96 ms
20,308 KB
testcase_19 AC 71 ms
19,084 KB
testcase_20 AC 86 ms
19,908 KB
testcase_21 AC 149 ms
20,272 KB
testcase_22 AC 122 ms
20,140 KB
testcase_23 AC 127 ms
20,128 KB
testcase_24 AC 128 ms
20,132 KB
testcase_25 AC 125 ms
20,260 KB
testcase_26 AC 127 ms
20,152 KB
testcase_27 AC 130 ms
20,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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};}

bool f(S a){
  return a.M<=a.m1+a.m2;
}


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 r=seg.max_right<f>(i);
    ans+=r-1-i;
  }
  
  pt(ans);
  
  
}




0