結果

問題 No.1705 Mode of long array
ユーザー noya2noya2
提出日時 2021-10-08 23:06:05
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 159 ms / 3,000 ms
コード長 4,366 bytes
コンパイル時間 4,625 ms
コンパイル使用メモリ 277,160 KB
実行使用メモリ 10,180 KB
最終ジャッジ日時 2023-09-30 12:30:31
合計ジャッジ時間 12,168 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 6 ms
4,376 KB
testcase_07 AC 8 ms
4,380 KB
testcase_08 AC 7 ms
4,380 KB
testcase_09 AC 6 ms
4,376 KB
testcase_10 AC 7 ms
4,376 KB
testcase_11 AC 6 ms
4,380 KB
testcase_12 AC 6 ms
4,376 KB
testcase_13 AC 109 ms
9,308 KB
testcase_14 AC 78 ms
6,452 KB
testcase_15 AC 73 ms
4,380 KB
testcase_16 AC 90 ms
4,380 KB
testcase_17 AC 65 ms
4,380 KB
testcase_18 AC 53 ms
4,380 KB
testcase_19 AC 99 ms
5,072 KB
testcase_20 AC 62 ms
4,984 KB
testcase_21 AC 85 ms
9,084 KB
testcase_22 AC 125 ms
9,572 KB
testcase_23 AC 86 ms
4,376 KB
testcase_24 AC 86 ms
4,376 KB
testcase_25 AC 86 ms
4,380 KB
testcase_26 AC 86 ms
4,376 KB
testcase_27 AC 86 ms
4,380 KB
testcase_28 AC 86 ms
4,376 KB
testcase_29 AC 86 ms
4,376 KB
testcase_30 AC 86 ms
4,380 KB
testcase_31 AC 86 ms
4,380 KB
testcase_32 AC 87 ms
4,376 KB
testcase_33 AC 157 ms
9,536 KB
testcase_34 AC 158 ms
9,548 KB
testcase_35 AC 156 ms
9,628 KB
testcase_36 AC 158 ms
9,628 KB
testcase_37 AC 158 ms
9,632 KB
testcase_38 AC 157 ms
9,716 KB
testcase_39 AC 157 ms
9,556 KB
testcase_40 AC 157 ms
9,684 KB
testcase_41 AC 159 ms
9,536 KB
testcase_42 AC 158 ms
9,628 KB
testcase_43 AC 104 ms
10,180 KB
testcase_44 AC 104 ms
10,180 KB
testcase_45 AC 105 ms
10,084 KB
testcase_46 AC 104 ms
10,176 KB
testcase_47 AC 104 ms
10,100 KB
testcase_48 AC 104 ms
10,088 KB
testcase_49 AC 146 ms
9,808 KB
testcase_50 AC 146 ms
9,856 KB
testcase_51 AC 146 ms
9,872 KB
testcase_52 AC 146 ms
9,812 KB
testcase_53 AC 146 ms
9,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
/*
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using bint = mp::cpp_int;
*/
#include <atcoder/all>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#include <bitset>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define repp(i,n,m) for (int i = m; i < int(n); ++i)
#define repb(i,n) for (int i = int(n)-1; i >= 0; --i)
#define fi first
#define se second
#define endl "\n"
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<long double, long double>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
const int INF = 1001001007;
const long long mod1 = 1000000007LL;
const long long mod2 = 998244353LL;
const ll inf = 2e18;
const ld pi = 3.14159265358979323;
const ld eps = 1e-7;
template<class T>istream &operator>>(istream &is,vector<T> &v){for(auto &e:v)is>>e;return is;}
template<class T>ostream &operator<<(ostream &os,const vector<T> &v){if(v.size()==0){os<<endl;}else{rep(i,v.size())os<<v[i]<<(i+1==v.size()?"\n":" ");}return os;}
template<class T>istream &operator>>(istream &is,vector<vector<T>> &v){for(auto &e:v)is>>e;return is;}
template<class T>ostream &operator<<(ostream &os,const vector<vector<T>> &v){if(v.size()==0){os<<endl;}else{for(auto &e:v)os<<e;}return os;}
template<typename T>bool range(T a,T b,T x){return (a<=x&&x<b);}
template<typename T>bool rrange(T a,T b,T c,T d,T x,T y){return (range(a,c,x)&&range(b,d,y));}
template<typename T>void rev(vector<T> &v){reverse(v.begin(),v.end());}
template<typename T>void sor(vector<T> &v, int f=0){sort(v.begin(),v.end());if(f!=0) rev(v);}
template<typename T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<typename T>void eru(vector<T> &v){sor(v);v.erase(unique(v.begin(),v.end()),v.end());}
template<typename T>T cel(T a,T b){if(a%b==0)return a/b;return a/b +1;}
template<typename T,typename U>void out2(T a,U b){cout<<a<<" "<<b<<endl;}
template<typename T>void mout(T a){cout<<a.val()<<endl;}
void yes(){cout << "Yes" << endl;}
void no (){cout << "No" << endl;}
void yn (bool t){if(t)yes();else no();}
void dame(bool t){if(t){cout << -1 << endl;exit(0);}}
void dout(ld h=-1.23456789){cout<<setprecision(20);if(abs(h+1.23456789)>eps)cout<<h<<endl;}
void deb(ll h = INF-1) {cout << (h == INF-1 ? "!?" : to_string(h)) << endl;}
void revs(string &s) {reverse(s.begin(),s.end());}
vector<int> dx = {0,1,0,-1};
vector<int> dy = {1,0,-1,0};
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string num = "0123456789";

ll gcds(ll a, ll b){
    a = abs(a); b = abs(b);
    if (b == 0) return a;
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

ll tentou(vector<ll> ar){
    int n = ar.size();
    set<ll> st;
    rep(i,n) st.insert(ar[i]);
    map<ll,int> mp;
    int ind = 0;
    for (ll x : st){
        mp[x] = ind;
        ind++;
    }
    fenwick_tree<ll> fw(ind);
    ll ans = 0;
    rep(i,n){
        int a = mp[ar[i]];
        ans += i - fw.sum(0,a+1);
        fw.add(a,1);
    }
    return ans;
}

/*
alias g++='g++ -I/mnt/c/Users/Owner/Desktop/ac-library'
*/

struct vs{
    vector<int> to;
};

struct S{
    int val;
    ll cnt;
    S (int _v = 0, ll _c = 0) : val(_v), cnt(_c) {}
};

S op (S a, S b){
    if (a.cnt > b.cnt) return a;
    if (a.cnt < b.cnt) return b;
    if (a.val > b.val) return a;
    return b;
}

S e(){
    return S();
}

int main(){
    ll n; cin >> n;
    int m; cin >> m;
    vector<ll> ar(m); cin >> ar;
    vector<S> a(m);
    rep(i,m) a[i] = S(i+1,ar[i]);
    segtree<S,op,e> seg(a);
    int q; cin >> q;
    vector<int> ans;
    rep(i,q){
        int t; cin >> t;
        if (t != 3){
            int x; cin >> x;
            ll y; cin >> y;
            if (t == 2) y *= -1;
            seg.set(x-1,S(x,seg.get(x-1).cnt+y));
        }
        if (t == 3){
            ll x, y; cin >> x >> y;
            ans.emplace_back(seg.all_prod().val);
        }
    }
    for (int x : ans) cout << x << endl;
}
0