結果

問題 No.3251 kthmex
ユーザー drkw1git
提出日時 2025-09-02 11:21:58
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 953 bytes
コンパイル時間 1,030 ms
コンパイル使用メモリ 85,428 KB
実行使用メモリ 16,456 KB
最終ジャッジ日時 2025-09-02 11:22:05
合計ジャッジ時間 6,123 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 4 TLE * 1 -- * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < m; ++i) {
        int t, l, r;
        cin >> t >> l >> r;
        if (t == 1) {
            int x, y;
            cin >> x >> y;
            for (int j = l; j <= r; ++j) {
                if (a[j] == x) a[j] = y;
            }
        } else {
            int k;
            cin >> k;
            set<int> b(a.begin(), a.end());
            vector<int> sorted_b(b.begin(), b.end());
            int s = 0, found = 0;
            for (int c : sorted_b) {
                if (k + s < c) {
                    cout << k + s << endl;
                    found = 1;
                    break;
                }
                s++;
            }
            if (!found) cout << k + s << endl;
        }
    }
    return 0;
}
0