結果
問題 | No.1435 Mmm...... |
ユーザー | Kude |
提出日時 | 2021-03-19 23:51:20 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 51 ms / 2,000 ms |
コード長 | 1,402 bytes |
コンパイル時間 | 4,500 ms |
コンパイル使用メモリ | 265,400 KB |
実行使用メモリ | 20,992 KB |
最終ジャッジ日時 | 2024-04-29 19:49:50 |
合計ジャッジ時間 | 6,425 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 30 ms
19,200 KB |
testcase_07 | AC | 34 ms
19,840 KB |
testcase_08 | AC | 39 ms
20,736 KB |
testcase_09 | AC | 38 ms
20,352 KB |
testcase_10 | AC | 32 ms
19,712 KB |
testcase_11 | AC | 33 ms
19,712 KB |
testcase_12 | AC | 31 ms
19,328 KB |
testcase_13 | AC | 30 ms
19,200 KB |
testcase_14 | AC | 21 ms
12,160 KB |
testcase_15 | AC | 41 ms
20,864 KB |
testcase_16 | AC | 37 ms
19,840 KB |
testcase_17 | AC | 24 ms
12,544 KB |
testcase_18 | AC | 40 ms
20,992 KB |
testcase_19 | AC | 33 ms
19,584 KB |
testcase_20 | AC | 37 ms
20,480 KB |
testcase_21 | AC | 51 ms
20,992 KB |
testcase_22 | AC | 44 ms
20,992 KB |
testcase_23 | AC | 46 ms
20,992 KB |
testcase_24 | AC | 48 ms
20,992 KB |
testcase_25 | AC | 48 ms
20,864 KB |
testcase_26 | AC | 48 ms
20,864 KB |
testcase_27 | AC | 47 ms
20,992 KB |
ソースコード
#include<bits/stdc++.h> #include<atcoder/all> using namespace std; using namespace atcoder; #define rep(i,n)for (int i = 0; i < int(n); ++i) #define rrep(i,n)for (int i = int(n)-1; i >= 0; --i) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() template<class T> void chmax(T& a, const T& b) {a = max(a, b);} template<class T> void chmin(T& a, const T& b) {a = min(a, b);} using ll = long long; using P = pair<int,int>; using VI = vector<int>; using VVI = vector<VI>; using VL = vector<ll>; using VVL = vector<VL>; struct S { ll m1, m2, M; }; S op(S x, S y) { ll M = max(x.M, y.M); ll m1, m2; if (x.m2 <= y.m1) { m1 = x.m1, m2 = x.m2; } else if (y.m2 <= x.m1) { m1 = y.m1, m2 = y.m2; } else { m1 = x.m1, m2 = y.m1; if (m1 > m2) swap(m1, m2); } return {m1, m2, M}; } constexpr ll INF = 1002003004005006007; S e() { return {INF, INF, -INF}; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; VI a(n); vector<S> init_vec(n); rep(i, n) { cin >> a[i]; init_vec[i] = {a[i], INF, a[i]}; } segtree<S, op, e> seg(init_vec); ll ans = 0; rep(i, n) { auto g = [&](S x) { return x.M <= x.m1 + x.m2; }; int r = seg.max_right(i, g); ans += max(0, r - i - 1); } cout << ans << endl; }