結果
| 問題 |
No.1705 Mode of long array
|
| コンテスト | |
| ユーザー |
harurun
|
| 提出日時 | 2021-09-22 19:43:57 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,490 bytes |
| コンパイル時間 | 892 ms |
| コンパイル使用メモリ | 85,188 KB |
| 最終ジャッジ日時 | 2025-01-24 16:14:27 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 46 TLE * 5 |
ソースコード
#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;
bool flag=false;
ll before;
for(ll i=0;i<Q;i++){
//cerr<<"i:"<<i<<endl;
ll T,X,Y;
cin>>T>>X>>Y;
if(T==1){
flag=false;
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){
flag=false;
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(flag){
cout<<before<<endl;
continue;
}
flag=true;
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;
before=ans;
}
}
return 0;
}
harurun