結果
問題 |
No.2957 Combo Deck Builder
|
ユーザー |
![]() |
提出日時 | 2024-11-08 23:10:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 600 bytes |
コンパイル時間 | 2,379 ms |
コンパイル使用メモリ | 201,140 KB |
最終ジャッジ日時 | 2025-02-25 03:09:38 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 15 WA * 23 |
ソースコード
#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]; G[C[i]].push_back(Y[i] - X[i]); } int k = 0; priority_queue<ll> que; for(int i = N; i >= 1; i--) { for(ll x : G[i]) que.push(x); if(que.empty()) { k++; }else { ll x = que.top(); if(x < 0 && k > 0) { k--; }else { ans += x, que.pop(); } } } cout << ans << endl; }