結果
問題 | No.878 Range High-Element Query |
ユーザー |
![]() |
提出日時 | 2024-06-14 09:17:17 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 847 ms / 2,000 ms |
コード長 | 706 bytes |
コンパイル時間 | 4,456 ms |
コンパイル使用メモリ | 256,832 KB |
最終ジャッジ日時 | 2025-02-21 21:36:37 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 18 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace std;using namespace atcoder;struct S {int mx;vector<int> vec;};S op(S a, S b) {S res;res.mx = max(a.mx, b.mx);vector<int> v = a.vec;for (int x : b.vec) {if (x > a.mx) {v.push_back(x);}}res.vec = v;return res;}S e() {return {0, {}};}int main() {int n, q;cin >> n >> q;segtree<S, op, e> seg(n);for (int i = 0; i < n; i++) {int a;cin >> a;seg.set(i, {a, {a}});}while (q--) {int t, l, r;cin >> t >> l >> r;l--;cout << seg.prod(l, r).vec.size() << endl;}}