結果

問題 No.1675 Strange Minimum Query
ユーザー mamimume____momamimume____mo
提出日時 2021-09-10 23:11:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,453 bytes
コンパイル時間 1,809 ms
コンパイル使用メモリ 184,572 KB
実行使用メモリ 35,068 KB
最終ジャッジ日時 2023-09-02 21:23:08
合計ジャッジ時間 14,046 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 543 ms
16,916 KB
testcase_04 AC 420 ms
17,204 KB
testcase_05 AC 26 ms
7,196 KB
testcase_06 AC 658 ms
19,336 KB
testcase_07 AC 668 ms
21,268 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 277 ms
21,056 KB
testcase_14 AC 439 ms
35,068 KB
testcase_15 AC 387 ms
30,436 KB
testcase_16 AC 2 ms
4,368 KB
testcase_17 AC 47 ms
5,976 KB
testcase_18 AC 72 ms
6,784 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 256 ms
15,400 KB
testcase_23 AC 220 ms
11,036 KB
testcase_24 AC 186 ms
11,564 KB
testcase_25 AC 139 ms
8,760 KB
testcase_26 WA -
testcase_27 AC 169 ms
12,980 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 292 ms
12,788 KB
testcase_32 AC 364 ms
18,168 KB
testcase_33 AC 350 ms
18,088 KB
testcase_34 AC 361 ms
18,164 KB
testcase_35 AC 322 ms
13,216 KB
testcase_36 AC 319 ms
13,324 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,INF);    

    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