結果

問題 No.2942 Sigma Music Game Level Problem
ユーザー haihamabossu
提出日時 2024-10-18 22:36:58
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 444 ms / 6,000 ms
コード長 927 bytes
コンパイル時間 2,100 ms
コンパイル使用メモリ 196,220 KB
最終ジャッジ日時 2025-02-24 20:59:30
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/fenwicktree>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

const ll MX = 200020;
void solve() {
  ll n, q, L;
  cin >> n >> q >> L;
  atcoder::fenwick_tree<ll> ft1(MX), ft2(MX);
  auto add = [&](ll a) -> void {
    ft1.add(a, 1);
    ft2.add(a, a);
  };
  rep(i, n) {
    ll a;
    cin >> a;
    add(a);
  }
  bool found = false;
  rep(qi, q) {
    ll t;
    cin >> t;
    if (t == 1) {
      ll l;
      cin >> l;
      add(l);
    }
    if (t == 2) {
      found = true;
      ll l, r;
      cin >> l >> r;
      cout << ft1.sum(l, r + 1) << ' ' << ft2.sum(l, r + 1) << '\n';
    }
    if (t == 3) {
      cin >> L;
    }
  }
  if (!found) {
    cout << "Not Found!\n";
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  int T = 1;
  for (int t = 0; t < T; t++) {
    solve();
  }
  return 0;
}
0