結果
問題 | No.1435 Mmm...... |
ユーザー | uzzy |
提出日時 | 2021-03-19 23:33:46 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 741 ms / 2,000 ms |
コード長 | 1,948 bytes |
コンパイル時間 | 5,697 ms |
コンパイル使用メモリ | 184,984 KB |
実行使用メモリ | 8,232 KB |
最終ジャッジ日時 | 2023-08-12 04:56:36 |
合計ジャッジ時間 | 15,673 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
6,532 KB |
testcase_01 | AC | 3 ms
6,584 KB |
testcase_02 | AC | 3 ms
6,580 KB |
testcase_03 | AC | 3 ms
6,580 KB |
testcase_04 | AC | 3 ms
6,588 KB |
testcase_05 | AC | 3 ms
6,672 KB |
testcase_06 | AC | 375 ms
7,556 KB |
testcase_07 | AC | 466 ms
7,968 KB |
testcase_08 | AC | 552 ms
8,044 KB |
testcase_09 | AC | 502 ms
7,940 KB |
testcase_10 | AC | 430 ms
7,680 KB |
testcase_11 | AC | 420 ms
7,856 KB |
testcase_12 | AC | 390 ms
7,876 KB |
testcase_13 | AC | 378 ms
7,608 KB |
testcase_14 | AC | 273 ms
7,304 KB |
testcase_15 | AC | 577 ms
8,024 KB |
testcase_16 | AC | 465 ms
7,796 KB |
testcase_17 | AC | 314 ms
7,432 KB |
testcase_18 | AC | 584 ms
8,032 KB |
testcase_19 | AC | 412 ms
7,936 KB |
testcase_20 | AC | 524 ms
7,904 KB |
testcase_21 | AC | 741 ms
8,060 KB |
testcase_22 | AC | 720 ms
8,232 KB |
testcase_23 | AC | 592 ms
8,048 KB |
testcase_24 | AC | 591 ms
8,024 KB |
testcase_25 | AC | 595 ms
8,056 KB |
testcase_26 | AC | 592 ms
8,060 KB |
testcase_27 | AC | 595 ms
8,132 KB |
ソースコード
#pragma GCC optimize ("O2") #pragma GCC target ("avx2") #include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (x) << " " #define ce(x) cerr << (x) << "\n" #define cesp(x) cerr << (x) << " " #define pb push_back #define mp make_pair #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) #define Would #define you #define please const int AS = 200200; pair<int, int> DAT[2 * AS]; int dat[2 * AS]; pair<int, int> keisan(pair<int, int> A, pair<int, int> B) { if (A > B) swap(A, B); if (A.second > B.first) swap(A.second, B.first); return A; } void modify(int p, int value) { for (DAT[p += AS] = { value, 2e9 }; p > 1; p >>= 1) { auto tmp = keisan(DAT[p], DAT[p ^ 1]); DAT[p >> 1] = tmp; } } pair<int, int> query(int l, int r) { pair<int, int> ret = { 2e9,2e9 }; for (l += AS, r += AS; l < r; l >>= 1, r >>= 1) { if (l & 1) ret = keisan(ret, DAT[l++]); if (r & 1) ret = keisan(ret, DAT[--r]); } return ret; } void modify2(int p, int value) { for (dat[p += AS] = value; p > 1; p >>= 1) dat[p >> 1] = max(dat[p], dat[p ^ 1]); } int query2(int l, int r) { int ret = 0; for (l += AS, r += AS; l < r; l >>= 1, r >>= 1) { if (l & 1) chmax(ret, dat[l++]); if (r & 1) chmax(ret, dat[--r]); } return ret; } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; rep(i, 2 * AS) { DAT[i] = { 2e9,2e9 }; } rep(i, N) { int a; cin >> a; modify(i, a); modify2(i, a); } ll kotae = 0; rep(i, N - 1) { int L = i + 1, R = N; while (L + 1 < R) { int wj = (L + R) / 2; auto p = query(i, wj + 1); ll dore = ll(query2(i, wj + 1)) - p.first - p.second; if (dore <= 0) L = wj; else R = wj; } kotae += L - i; } co(kotae); Would you please return 0; }