結果

問題 No.1675 Strange Minimum Query
ユーザー mamimume____momamimume____mo
提出日時 2021-09-10 23:12:23
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 617 ms / 2,000 ms
コード長 1,460 bytes
コンパイル時間 2,042 ms
コンパイル使用メモリ 184,200 KB
実行使用メモリ 35,208 KB
最終ジャッジ日時 2023-09-02 21:25:56
合計ジャッジ時間 14,558 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 490 ms
17,124 KB
testcase_04 AC 377 ms
17,364 KB
testcase_05 AC 25 ms
7,300 KB
testcase_06 AC 616 ms
19,704 KB
testcase_07 AC 617 ms
21,320 KB
testcase_08 AC 1 ms
4,368 KB
testcase_09 AC 3 ms
4,368 KB
testcase_10 AC 160 ms
12,796 KB
testcase_11 AC 26 ms
7,212 KB
testcase_12 AC 174 ms
13,924 KB
testcase_13 AC 274 ms
21,064 KB
testcase_14 AC 435 ms
35,208 KB
testcase_15 AC 388 ms
30,308 KB
testcase_16 AC 1 ms
4,372 KB
testcase_17 AC 45 ms
6,008 KB
testcase_18 AC 70 ms
6,840 KB
testcase_19 AC 84 ms
10,372 KB
testcase_20 AC 224 ms
12,920 KB
testcase_21 AC 189 ms
13,292 KB
testcase_22 AC 254 ms
15,532 KB
testcase_23 AC 215 ms
11,188 KB
testcase_24 AC 182 ms
11,480 KB
testcase_25 AC 139 ms
8,600 KB
testcase_26 AC 62 ms
7,324 KB
testcase_27 AC 166 ms
12,968 KB
testcase_28 AC 81 ms
8,956 KB
testcase_29 AC 50 ms
9,232 KB
testcase_30 AC 59 ms
7,100 KB
testcase_31 AC 284 ms
12,728 KB
testcase_32 AC 355 ms
18,300 KB
testcase_33 AC 346 ms
18,088 KB
testcase_34 AC 363 ms
18,040 KB
testcase_35 AC 316 ms
13,276 KB
testcase_36 AC 318 ms
13,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000100;
const ll INFL = 2e18;
template <class T>bool chmin(T &a, T b){ if (a > b) { a = b; return true;} else return false;}
template <class T>bool chmax(T &a, T b){ if (a < b) { a = b; return true;} else return false;}

using P = pair<int,int>;

int main() {
    int N,Q;
    cin >> N >> Q;

    vector<int> ans(N,1000000000);    

    multiset<int> st;
    vector<vector<P>> query(N);
    priority_queue<P, vector<P>, greater<P>> pq;
    for (int i = 0;i < Q;i++) {
        int l, r, B;
        cin >> l >> r >> B;
        l--, r--;
        query[l].push_back({r, B});
    }

    int rem = Q;
    map<int,int> mp;
    
    for (int i = 0;i < N;i++) {
        for (int j = 0;j < query[i].size();j++) {
            int r, B;
            tie(r, B) = query[i][j];
            st.insert(B);
            pq.push({r, B});
            mp[B]++;
        }
        if (st.size()) {
            ans[i] = *st.rbegin();
            rem -= mp[*st.rbegin()];
            mp[*st.rbegin()] = 0;
        }

        while (pq.size() && i == pq.top().first) {
            int r,B;
            tie(r, B) = pq.top();
            pq.pop();
            st.erase(st.find(B));
        }
    }

    if (rem) {
        cout << -1 << endl;
    }
    else {
        for (int i = 0;i < N;i++) {
            if (i != N-1)cout << ans[i] << " ";
            else cout << ans[i] << endl;
        }
    }
}
0