結果
問題 | No.1441 MErGe |
ユーザー | りあん |
提出日時 | 2021-03-26 22:55:23 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 392 ms / 1,000 ms |
コード長 | 1,264 bytes |
コンパイル時間 | 2,711 ms |
コンパイル使用メモリ | 208,080 KB |
実行使用メモリ | 7,580 KB |
最終ジャッジ日時 | 2023-08-19 09:37:04 |
合計ジャッジ時間 | 11,685 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 3 ms
4,380 KB |
testcase_04 | AC | 3 ms
4,376 KB |
testcase_05 | AC | 8 ms
4,380 KB |
testcase_06 | AC | 8 ms
4,380 KB |
testcase_07 | AC | 8 ms
4,380 KB |
testcase_08 | AC | 78 ms
4,380 KB |
testcase_09 | AC | 78 ms
4,380 KB |
testcase_10 | AC | 142 ms
4,380 KB |
testcase_11 | AC | 128 ms
4,376 KB |
testcase_12 | AC | 139 ms
4,380 KB |
testcase_13 | AC | 321 ms
7,256 KB |
testcase_14 | AC | 334 ms
7,292 KB |
testcase_15 | AC | 349 ms
7,204 KB |
testcase_16 | AC | 317 ms
7,160 KB |
testcase_17 | AC | 312 ms
7,208 KB |
testcase_18 | AC | 237 ms
6,696 KB |
testcase_19 | AC | 268 ms
7,024 KB |
testcase_20 | AC | 210 ms
6,764 KB |
testcase_21 | AC | 186 ms
5,336 KB |
testcase_22 | AC | 285 ms
5,376 KB |
testcase_23 | AC | 392 ms
7,444 KB |
testcase_24 | AC | 392 ms
7,472 KB |
testcase_25 | AC | 389 ms
7,420 KB |
testcase_26 | AC | 391 ms
7,564 KB |
testcase_27 | AC | 391 ms
7,468 KB |
testcase_28 | AC | 391 ms
7,516 KB |
testcase_29 | AC | 392 ms
7,580 KB |
ソースコード
#include<bits/stdc++.h> #include<atcoder/lazysegtree> using namespace std; using P = pair<int, int>; const int M = 1000000007; // const int M = 998244353; const long long LM = 1LL << 60; int op(int a, int b) { return a + b; } int e() { return 0; } int mapping(bool a, int b) { return a ? 0 : b; } bool composition(bool a, bool b) { return a || b; } bool id() { return false; } int main() { cin.tie(0); ios::sync_with_stdio(0); int n, q; cin >> n >> q; vector<long long> imos(n + 1); for (int i = 0; i < n; ++i) { int a; cin >> a; imos[i + 1] = imos[i] + a; } atcoder::lazy_segtree<int, op, e, bool, mapping, composition, id> sg(vector<int>(n, 1)); for (int _ = 0; _ < q; ++_) { int t, l, r; cin >> t >> l >> r; --l; if (t == 1) { int ll = sg.max_right(0, [&](int x){ return x <= l; }); int rr = sg.max_right(0, [&](int x){ return x <= r; }); sg.apply(ll + 1, rr, true); } else { int ll = sg.max_right(0, [&](int x){ return x <= l; }); int rr = sg.max_right(0, [&](int x){ return x <= r; }); cout << imos[rr] - imos[ll] << '\n'; } } return 0; }