結果

問題 No.1705 Mode of long array
ユーザー milanis48663220milanis48663220
提出日時 2021-10-08 22:41:08
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 212 ms / 3,000 ms
コード長 2,276 bytes
コンパイル時間 1,189 ms
コンパイル使用メモリ 124,584 KB
実行使用メモリ 10,332 KB
最終ジャッジ日時 2023-09-30 11:42:30
合計ジャッジ時間 9,757 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 8 ms
4,376 KB
testcase_07 AC 9 ms
4,376 KB
testcase_08 AC 9 ms
4,380 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 AC 8 ms
4,380 KB
testcase_11 AC 8 ms
4,380 KB
testcase_12 AC 8 ms
4,376 KB
testcase_13 AC 157 ms
8,596 KB
testcase_14 AC 104 ms
6,260 KB
testcase_15 AC 88 ms
4,376 KB
testcase_16 AC 113 ms
4,384 KB
testcase_17 AC 78 ms
4,380 KB
testcase_18 AC 64 ms
4,376 KB
testcase_19 AC 130 ms
5,352 KB
testcase_20 AC 78 ms
5,044 KB
testcase_21 AC 120 ms
7,744 KB
testcase_22 AC 199 ms
9,632 KB
testcase_23 AC 52 ms
4,380 KB
testcase_24 AC 53 ms
4,380 KB
testcase_25 AC 53 ms
4,380 KB
testcase_26 AC 53 ms
4,376 KB
testcase_27 AC 52 ms
4,376 KB
testcase_28 AC 53 ms
4,380 KB
testcase_29 AC 52 ms
4,376 KB
testcase_30 AC 52 ms
4,380 KB
testcase_31 AC 52 ms
4,376 KB
testcase_32 AC 53 ms
4,376 KB
testcase_33 AC 200 ms
10,116 KB
testcase_34 AC 191 ms
10,112 KB
testcase_35 AC 190 ms
10,120 KB
testcase_36 AC 196 ms
10,116 KB
testcase_37 AC 207 ms
10,176 KB
testcase_38 AC 212 ms
10,184 KB
testcase_39 AC 199 ms
10,332 KB
testcase_40 AC 192 ms
10,216 KB
testcase_41 AC 190 ms
10,232 KB
testcase_42 AC 195 ms
10,120 KB
testcase_43 AC 198 ms
10,116 KB
testcase_44 AC 193 ms
10,112 KB
testcase_45 AC 196 ms
10,180 KB
testcase_46 AC 193 ms
10,220 KB
testcase_47 AC 190 ms
10,236 KB
testcase_48 AC 193 ms
10,176 KB
testcase_49 AC 152 ms
10,164 KB
testcase_50 AC 152 ms
10,232 KB
testcase_51 AC 153 ms
10,124 KB
testcase_52 AC 152 ms
10,116 KB
testcase_53 AC 151 ms
10,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}

template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}

template <typename T>
struct bit{
    int n;
    vector<T> data;

    bit(int n_){
        n = 1;
        while(n < n_) n *= 2;
        data = vector<T>(n+1);
        for(int i = 0; i <= n; i++) data[i] = 0;
    }
    
    T sum(int i){
        T ret = 0;
        while(i > 0){
            ret += data[i];
            i -= i&-i;
        }
        return ret;
    }

    void add(int i, T x){
        while(i <= n){
            data[i] += x;
            i += i&-i;
        }
    }
};

using P = pair<ll, int>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    ll n, m; cin >> n >> m;
    vector<ll> a(m+1);
    set<P> st;
    for(int i = 1; i <= m; i++) {
        cin >> a[i];
        st.insert(P(a[i], i));
    }
    int q; cin >> q;
    auto set_val = [&](int i, ll x){
        st.erase(P(a[i], i));
        a[i] = x;
        st.insert(P(a[i], i));
    };
    while(q--){
        int t, x; ll y; cin >> t >> x >> y;
        if(t == 1) set_val(x, a[x]+y);
        if(t == 2) set_val(x, a[x]-y);
        if(t == 3){
            auto p = st.end(); p--;
            cout << p->second << endl;
        }
    }
}
0