結果

問題 No.1705 Mode of long array
ユーザー harurun
提出日時 2021-10-02 10:49:48
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 244 ms / 3,000 ms
コード長 820 bytes
コンパイル時間 1,067 ms
コンパイル使用メモリ 93,528 KB
最終ジャッジ日時 2025-01-24 19:54:50
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/segtree>
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
using namespace atcoder;
using ll=long long;
using Pll=pair<ll,ll>;

Pll op(Pll a,Pll b){
  if(a.first>b.first){
    return a;
  }else{
    return b;
  }
}

Pll e(){
  return make_pair(-1LL,-1LL);
}

int main(){
  ll N,M;
  cin>>N>>M;
  vector<Pll>A(M);
  for(int i=0;i<M;i++){
    cin>>A.at(i).first;
    A.at(i).second=i+1;
  }
  ll Q;
  cin>>Q;
  segtree<Pll,op,e> seg(A);
  for(int i=0;i<Q;i++){
    ll T,X,Y;
    cin>>T>>X>>Y;
    if(T==1){
      Pll d=seg.get(X-1);
      seg.set(X-1,make_pair(d.first+Y,d.second));
    }else if(T==2){
      Pll d=seg.get(X-1);
      seg.set(X-1,make_pair(d.first-Y,d.second));
    }else{
      cout<<seg.all_prod().second<<endl;
    }
  }
  return 0;
}
0