結果

問題 No.1435 Mmm......
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-03-19 22:55:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 1,242 bytes
コンパイル時間 1,527 ms
コンパイル使用メモリ 175,168 KB
実行使用メモリ 4,920 KB
最終ジャッジ日時 2023-08-12 03:50:34
合計ジャッジ時間 4,364 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 40 ms
4,380 KB
testcase_07 AC 48 ms
4,388 KB
testcase_08 AC 56 ms
4,920 KB
testcase_09 AC 52 ms
4,480 KB
testcase_10 AC 43 ms
4,376 KB
testcase_11 AC 44 ms
4,380 KB
testcase_12 AC 41 ms
4,380 KB
testcase_13 AC 39 ms
4,380 KB
testcase_14 AC 30 ms
4,380 KB
testcase_15 AC 56 ms
4,568 KB
testcase_16 AC 50 ms
4,384 KB
testcase_17 AC 37 ms
4,380 KB
testcase_18 AC 59 ms
4,560 KB
testcase_19 AC 42 ms
4,376 KB
testcase_20 AC 53 ms
4,476 KB
testcase_21 AC 66 ms
4,576 KB
testcase_22 AC 30 ms
4,712 KB
testcase_23 AC 93 ms
4,672 KB
testcase_24 AC 92 ms
4,612 KB
testcase_25 AC 89 ms
4,628 KB
testcase_26 AC 89 ms
4,612 KB
testcase_27 AC 88 ms
4,668 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘std::vector<long long int> dfs(ll, ll)’ 内:
main.cpp:25:1: 警告: 非 void を戻す関数内に return 文がありません [-Wreturn-type]
   25 | }
      | ^

ソースコード

diff #

#include <bits/stdc++.h>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <bitset>
#include <map>
#include <cassert>
#include <set>

using namespace std;

using ll = long long;
#define rep(i,n,m) for(ll (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(ll (i)=(n);(i)>(m);(i)--)

ll mmd(ll x){
    x %= 998244353;
    if (x < 0) return x + 998244353;
    else return x;
}

vector<ll> dfs(ll v,ll p){
    
}

int main(){

    ll N;
    cin >> N;
    vector<ll> a(N);
    rep(i,0,N) cin >> a[i];

    map<ll,ll> s;
    s[a[0]] += 1;
    ll l;
    l = 0; // 次に削除する奴
    ll ans = 0;

    rep(r,1,N){

        
        s[a[r]] += 1;

        while (1){
            
            ll m1,m2,M;
            M = s.rbegin()->first;
            m1 = s.begin()->first;
            if (s[m1] > 1){
                m2 = m1;
            }else{
                m2 = (++s.begin())->first;
            }
            
            //cout << l << " " << r << " " << m1 << " " << m2 << " " << M << endl;
            if (M <= m1 + m2) break;

            s[a[l]] -= 1;
            if (s[a[l]] == 0) s.erase(a[l]);
            l += 1;
            

        }

        ans += (r-l);

    }

    cout << ans << '\n';

}
0