結果

問題 No.759 悪くない忘年会にしような!
ユーザー rpy3cpprpy3cpp
提出日時 2019-05-14 12:25:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 1,594 bytes
コンパイル時間 1,905 ms
コンパイル使用メモリ 182,220 KB
実行使用メモリ 5,680 KB
最終ジャッジ日時 2023-09-25 12:33:50
合計ジャッジ時間 5,917 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 4 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 3 ms
4,380 KB
testcase_36 AC 4 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 4 ms
4,376 KB
testcase_39 AC 3 ms
4,380 KB
testcase_40 AC 4 ms
4,376 KB
testcase_41 AC 4 ms
4,376 KB
testcase_42 AC 5 ms
4,376 KB
testcase_43 AC 5 ms
4,380 KB
testcase_44 AC 37 ms
4,640 KB
testcase_45 AC 37 ms
4,668 KB
testcase_46 AC 37 ms
4,604 KB
testcase_47 AC 37 ms
4,592 KB
testcase_48 AC 37 ms
4,524 KB
testcase_49 AC 5 ms
4,376 KB
testcase_50 AC 5 ms
4,380 KB
testcase_51 AC 5 ms
4,380 KB
testcase_52 AC 5 ms
4,376 KB
testcase_53 AC 36 ms
4,592 KB
testcase_54 AC 36 ms
4,684 KB
testcase_55 AC 36 ms
4,592 KB
testcase_56 AC 37 ms
4,696 KB
testcase_57 AC 37 ms
4,668 KB
testcase_58 AC 37 ms
4,520 KB
testcase_59 AC 36 ms
4,588 KB
testcase_60 AC 37 ms
4,640 KB
testcase_61 AC 37 ms
4,524 KB
testcase_62 AC 36 ms
4,632 KB
testcase_63 AC 64 ms
5,628 KB
testcase_64 AC 65 ms
5,680 KB
testcase_65 AC 36 ms
4,840 KB
testcase_66 AC 62 ms
5,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

struct PTR{
    int P, T, R, idx;
    PTR(int p=0, int t=0, int r=0, int i=0):P(p), T(t), R(r), idx(i){}
    bool operator<(const PTR &rhs){
        if (P > rhs.P){
            return true;
        }else if (P < rhs.P){
            return false;
        }else if (T > rhs.T){
            return true;
        }else if (T < rhs.T){
            return false;
        }else if (R > rhs.R){
            return true;
        }else{
            return false;
        }
    }
};

ostream &operator<<(ostream &stream, const PTR &ptr){
    stream << '(' << ptr.P << ", " << ptr.T << ", " << ptr.R << ", " << ptr.idx << ')';
    return stream;
};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<PTR> ptrs(N);
    for (int i = 0; i < N; ++i){
        cin >> ptrs[i].P >> ptrs[i].T >> ptrs[i].R;
        ptrs[i].idx = i + 1;
    }
    sort(ptrs.begin(), ptrs.end());
    map<int, int> trs;
    trs[-1] = 1e9;
    trs[20000] = -1;
    vector<int> ans;
    for (auto &ptr : ptrs){
        auto right = trs.lower_bound(ptr.T);
        if (right->second >= ptr.R) continue;
        ans.push_back(ptr.idx);
        if (right->first == ptr.T and right->second < ptr.R){
            right->second = ptr.R;
        }else{
            right = trs.insert(right, make_pair(ptr.T, ptr.R));
        }
        auto left = right;
        while (left->second <= ptr.R) --left;
        ++left;
        trs.erase(left, right);
    }
    sort(ans.begin(), ans.end());
    for (auto & a : ans) cout << a << '\n';
    return 0;
}
0