結果
問題 | No.1435 Mmm...... |
ユーザー |
👑 ![]() |
提出日時 | 2021-03-19 22:55:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 100 ms / 2,000 ms |
コード長 | 1,242 bytes |
コンパイル時間 | 2,027 ms |
コンパイル使用メモリ | 177,064 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-19 00:23:40 |
合計ジャッジ時間 | 4,270 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 24 |
コンパイルメッセージ
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 | } | ^
ソースコード
#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'; }