結果

問題 No.759 悪くない忘年会にしような!
ユーザー 0w1
提出日時 2018-12-10 03:09:08
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 1,094 bytes
コンパイル時間 2,230 ms
コンパイル使用メモリ 206,824 KB
最終ジャッジ日時 2025-01-06 18:49:57
ジャッジサーバーID
(参考情報)
judge4 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 64
権限があれば一括ダウンロードができます

ソースコード

diff #

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

struct Ftree {
  vector<int> dat;
  Ftree(int n) : dat(n, -1) {}
  void add(int x, int v) {
    for (int i = x; i; i -= i & -i) dat[i] = max(dat[i], v);
  }
  int sum(int x) { 
    int res = dat[x];
    for (int i = x; i < dat.size(); i += i & -i) res = max(res, dat[i]);
    return res;
  }
};

signed main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  vector<int> P(N), T(N), R(N);
  for (int i = 0; i < N; ++i) cin >> P[i] >> T[i] >> R[i];

  vector<int> ord(N);
  iota(ord.begin(), ord.end(), 0);
  sort(ord.begin(), ord.end(),
      [&](int i, int j) { return make_tuple(P[i], T[i], R[i]) < make_tuple(P[j], T[j], R[j]); });
  reverse(ord.begin(), ord.end());

  vector<int> res;
  Ftree ftree(1 << 14);
  for (int i = 0; i < N; ++i) {
    int t = T[ord[i]];
    int r = R[ord[i]];
    if (ftree.sum(t + 1) < r) res.push_back(ord[i]);
    ftree.add(t + 1, r);
  }

  sort(res.begin(), res.end());
  for (int i = 0; i < res.size(); ++i) ++res[i];
  copy(res.begin(), res.end(), ostream_iterator<int>(cout, "\n"));

  return 0;
}
0