結果

問題 No.2957 Combo Deck Builder
ユーザー ripity
提出日時 2024-11-08 23:05:17
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 491 bytes
コンパイル時間 2,188 ms
コンパイル使用メモリ 201,160 KB
最終ジャッジ日時 2025-02-25 03:06:40
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using ll = long long;

int main() {
  int N;
  cin >> N;
  ll ans = 0;
  vector<ll> C(N), X(N), Y(N);
  vector<vector<ll>> G(N + 1);
  for(int i = 0; i < N; i++) {
    cin >> C[i] >> X[i] >> Y[i];
    ans += X[i];
    if(Y[i] - X[i] > 0) G[C[i]].push_back(Y[i] - X[i]);
  }
  priority_queue<ll> que;
  for(int i = N; i >= 1; i--) {
    for(ll x : G[i]) que.push(x);
    if(!que.empty()) ans += que.top(), que.pop();
  }
  cout << ans << endl;
}
0