結果
問題 | No.1705 Mode of long array |
ユーザー |
![]() |
提出日時 | 2021-10-08 23:12:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 71 ms / 3,000 ms |
コード長 | 1,519 bytes |
コンパイル時間 | 1,978 ms |
コンパイル使用メモリ | 199,520 KB |
最終ジャッジ日時 | 2025-01-24 23:19:07 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 51 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)// Ref: https://qiita.com/ysuzuki19/items/d89057d65284ba1a16ac#define dump(var) do{std::cerr << #var << " : ";view(var);}while(0)template<typename T> void view(T e){std::cerr << e << "\n";}template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cerr << e << " "; } std::cerr << "\n";}template<typename T> void view(const std::vector<std::vector<T> >& vv){ std::cerr << "\n"; for(const auto& v : vv){ view(v); } }template<typename T> void dump_cout(const T& v) { for(long long i = 0; i < v.size(); i++) std::cout << v[i] << (i == v.size()-1 ? "\n" : " "); }#include <atcoder/segtree>using namespace atcoder;using S = pair<ll, ll>;S op(S a, S b) { return max(a, b); }S e() { return {0, 0}; }void solve() {ll n, m;cin >> n >> m;vector<S> a(m);rep(i, 0, m) {cin >> a[i].first;a[i].second = i+1;}segtree<S, op, e> seg(a);ll q;cin >> q;while(q--) {ll t, x, y;cin >> t >> x >> y;x--;if(t == 1) {seg.set(x, {seg.get(x).first + y, x+1});}if(t == 2) {seg.set(x, {seg.get(x).first - y, x+1});}if(t == 3) {cout << seg.all_prod().second << "\n";}}}int main() {ios::sync_with_stdio(false);cin.tie(nullptr);solve();return 0;}