結果

問題 No.1435 Mmm......
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-03-19 22:55:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 1,242 bytes
コンパイル時間 2,257 ms
コンパイル使用メモリ 176,964 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 18:21:13
合計ジャッジ時間 4,296 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 46 ms
5,376 KB
testcase_07 AC 54 ms
5,376 KB
testcase_08 AC 63 ms
5,376 KB
testcase_09 AC 57 ms
5,376 KB
testcase_10 AC 50 ms
5,376 KB
testcase_11 AC 50 ms
5,376 KB
testcase_12 AC 46 ms
5,376 KB
testcase_13 AC 45 ms
5,376 KB
testcase_14 AC 35 ms
5,376 KB
testcase_15 AC 65 ms
5,376 KB
testcase_16 AC 55 ms
5,376 KB
testcase_17 AC 39 ms
5,376 KB
testcase_18 AC 66 ms
5,376 KB
testcase_19 AC 49 ms
5,376 KB
testcase_20 AC 61 ms
5,376 KB
testcase_21 AC 77 ms
5,376 KB
testcase_22 AC 35 ms
5,376 KB
testcase_23 AC 104 ms
5,376 KB
testcase_24 AC 103 ms
5,376 KB
testcase_25 AC 104 ms
5,376 KB
testcase_26 AC 104 ms
5,376 KB
testcase_27 AC 105 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'std::vector<long long int> dfs(ll, ll)':
main.cpp:25:1: warning: no return statement in function returning non-void [-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