結果

問題 No.1705 Mode of long array
ユーザー harurunharurun
提出日時 2021-09-22 13:01:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,317 bytes
コンパイル時間 1,049 ms
コンパイル使用メモリ 87,740 KB
実行使用メモリ 10,288 KB
最終ジャッジ日時 2023-09-30 09:40:13
合計ジャッジ時間 13,871 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 4 ms
4,376 KB
testcase_05 AC 5 ms
4,376 KB
testcase_06 AC 13 ms
4,376 KB
testcase_07 AC 15 ms
4,376 KB
testcase_08 AC 14 ms
4,380 KB
testcase_09 AC 12 ms
4,376 KB
testcase_10 AC 11 ms
4,376 KB
testcase_11 AC 14 ms
4,376 KB
testcase_12 AC 13 ms
4,380 KB
testcase_13 AC 234 ms
8,600 KB
testcase_14 AC 156 ms
6,244 KB
testcase_15 AC 138 ms
4,376 KB
testcase_16 AC 173 ms
4,416 KB
testcase_17 AC 122 ms
4,376 KB
testcase_18 AC 100 ms
4,380 KB
testcase_19 AC 209 ms
5,284 KB
testcase_20 AC 123 ms
4,812 KB
testcase_21 AC 179 ms
7,876 KB
testcase_22 AC 284 ms
9,776 KB
testcase_23 AC 117 ms
4,376 KB
testcase_24 AC 116 ms
4,380 KB
testcase_25 AC 117 ms
4,376 KB
testcase_26 AC 117 ms
4,380 KB
testcase_27 AC 117 ms
4,380 KB
testcase_28 AC 116 ms
4,376 KB
testcase_29 AC 117 ms
4,376 KB
testcase_30 AC 117 ms
4,376 KB
testcase_31 AC 116 ms
4,376 KB
testcase_32 AC 117 ms
4,376 KB
testcase_33 AC 305 ms
10,216 KB
testcase_34 AC 308 ms
10,288 KB
testcase_35 AC 312 ms
10,164 KB
testcase_36 AC 316 ms
10,152 KB
testcase_37 AC 300 ms
10,228 KB
testcase_38 AC 310 ms
10,128 KB
testcase_39 AC 310 ms
10,288 KB
testcase_40 AC 308 ms
10,288 KB
testcase_41 AC 304 ms
10,216 KB
testcase_42 AC 306 ms
10,156 KB
testcase_43 TLE -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;
using ll=long long;
using Pll=pair<ll,ll>;

int main(){
  ll N,M;
  cin>>N>>M;
  vector<ll> a(M);
  for(ll i=0;i<M;i++){
    cin>>a.at(i);
  }
  multiset<Pll> ms;
  for(ll i=0;i<M;i++){
    ms.insert(make_pair(a.at(i),i+1));
  }
  ll Q;
  cin>>Q;
  for(ll i=0;i<Q;i++){
    //cerr<<"i:"<<i<<endl;
    ll T,X,Y;
    cin>>T>>X>>Y;
    if(T==1){
      auto it=ms.lower_bound(make_pair(a.at(X-1),-1));
      auto last=ms.upper_bound(make_pair(a.at(X-1)+1,-1));
      for(;it!=last;it++){
        if((*it).second==X){
          ms.erase(it);
          break;
        }
      }
      a.at(X-1)+=Y;
      ms.insert(make_pair(a.at(X-1),X));
    }else if(T==2){
      auto it=ms.lower_bound(make_pair(a.at(X-1),-1));
      auto last=ms.upper_bound(make_pair(a.at(X-1)+1,-1));
      for(;it!=last;it++){
        if((*it).second==X){
          ms.erase(it);
          break;
        }
      }
      a.at(X-1)-=Y;
      ms.insert(make_pair(a.at(X-1),X));
    }else{
      auto it=ms.lower_bound(make_pair((*ms.rbegin()).first,-1));
      auto last=ms.upper_bound(make_pair((*ms.rbegin()).first+1,-1));
      ll ans=0;
      for(;it!=last;it++){
        ans=max(ans,(*it).second);
      }
      cout<<ans<<endl;
    }
  }
  return 0;
}
0