結果
問題 | No.2957 Combo Deck Builder |
ユーザー |
👑 ![]() |
提出日時 | 2024-11-08 22:28:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 217 ms / 1,000 ms |
コード長 | 1,344 bytes |
コンパイル時間 | 1,221 ms |
コンパイル使用メモリ | 87,428 KB |
最終ジャッジ日時 | 2025-02-25 02:52:31 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 38 |
ソースコード
#ifdef NACHIA #define _GLIBCXX_DEBUG #else #define NDEBUG #endif #include <iostream> #include <string> #include <vector> #include <algorithm> using i64 = long long; using u64 = unsigned long long; #define rep(i,n) for(int i=0; i<int(n); i++) const i64 INF = 1001001001001001001; template<typename A> void chmin(A& l, const A& r){ if(r < l) l = r; } template<typename A> void chmax(A& l, const A& r){ if(l < r) l = r; } #include <atcoder/modint> #include <queue> using Modint = atcoder::static_modint<998244353>; using namespace std; void testcase(){ i64 N; cin >> N; vector<pair<i64,i64>> A, B; i64 ans = 0; rep(i,N){ i64 c,x,y; cin >> c >> x >> y; ans += min(x,y); if(x > y) A.push_back({ N-1-c,x-y }); else B.push_back({ c-1,y-x }); } rep(t,2){ sort(A.begin(), A.end()); i64 n = i64(A.size()); priority_queue<i64> que; for(i64 t=n-1; t>=0; t--){ while(A.size() && A.back().first >= t){ que.push(A.back().second); A.pop_back(); } if(!que.empty()){ ans += que.top(); que.pop(); } } swap(A,B); } cout << ans << endl; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); testcase(); return 0; }