結果

問題 No.1705 Mode of long array
ユーザー harurunharurun
提出日時 2021-10-02 10:49:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 218 ms / 3,000 ms
コード長 820 bytes
コンパイル時間 769 ms
コンパイル使用メモリ 80,016 KB
実行使用メモリ 9,008 KB
最終ジャッジ日時 2023-09-30 09:43:13
合計ジャッジ時間 10,089 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 4 ms
4,376 KB
testcase_06 AC 8 ms
4,376 KB
testcase_07 AC 10 ms
4,380 KB
testcase_08 AC 9 ms
4,380 KB
testcase_09 AC 8 ms
4,380 KB
testcase_10 AC 8 ms
4,376 KB
testcase_11 AC 9 ms
4,376 KB
testcase_12 AC 8 ms
4,376 KB
testcase_13 AC 121 ms
8,240 KB
testcase_14 AC 88 ms
6,092 KB
testcase_15 AC 94 ms
4,376 KB
testcase_16 AC 114 ms
4,380 KB
testcase_17 AC 87 ms
4,376 KB
testcase_18 AC 71 ms
4,380 KB
testcase_19 AC 131 ms
4,576 KB
testcase_20 AC 80 ms
4,380 KB
testcase_21 AC 95 ms
8,188 KB
testcase_22 AC 139 ms
8,472 KB
testcase_23 AC 77 ms
4,376 KB
testcase_24 AC 78 ms
4,376 KB
testcase_25 AC 77 ms
4,380 KB
testcase_26 AC 78 ms
4,376 KB
testcase_27 AC 78 ms
4,384 KB
testcase_28 AC 76 ms
4,376 KB
testcase_29 AC 79 ms
4,380 KB
testcase_30 AC 79 ms
4,384 KB
testcase_31 AC 79 ms
4,380 KB
testcase_32 AC 78 ms
4,376 KB
testcase_33 AC 130 ms
8,924 KB
testcase_34 AC 132 ms
8,668 KB
testcase_35 AC 130 ms
8,836 KB
testcase_36 AC 132 ms
8,932 KB
testcase_37 AC 132 ms
8,664 KB
testcase_38 AC 136 ms
9,008 KB
testcase_39 AC 133 ms
8,832 KB
testcase_40 AC 131 ms
8,724 KB
testcase_41 AC 132 ms
8,928 KB
testcase_42 AC 130 ms
8,800 KB
testcase_43 AC 204 ms
8,796 KB
testcase_44 AC 204 ms
8,860 KB
testcase_45 AC 203 ms
8,748 KB
testcase_46 AC 217 ms
8,932 KB
testcase_47 AC 218 ms
8,764 KB
testcase_48 AC 212 ms
8,800 KB
testcase_49 AC 152 ms
8,680 KB
testcase_50 AC 151 ms
8,732 KB
testcase_51 AC 150 ms
8,924 KB
testcase_52 AC 148 ms
8,716 KB
testcase_53 AC 154 ms
9,004 KB
権限があれば一括ダウンロードができます

ソースコード

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