結果
問題 | No.2957 Combo Deck Builder |
ユーザー |
👑 ![]() |
提出日時 | 2024-11-08 22:00:31 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 332 ms / 1,000 ms |
コード長 | 1,435 bytes |
コンパイル時間 | 2,219 ms |
コンパイル使用メモリ | 207,052 KB |
最終ジャッジ日時 | 2025-02-25 02:47:08 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 38 |
ソースコード
#include <bits/stdc++.h> using namespace std; //https://atcoder.jp/contests/aising2020/submissions/15187101 int main() { int T = 1; // cin>>T; for(int i=0;i<T;i++){ int N; int64_t Z=0; cin>>N; vector<pair<int,int64_t>> l; vector<pair<int,int64_t>> r; for(int i=0;i<N;i++){ int a; int64_t b,c; cin>>a>>b>>c; swap(b, c); if(b>c){ Z+=c; l.push_back(make_pair(a,b-c)); } else if(c>b&&a!=N){ Z+=b; r.push_back(make_pair(N-a,c-b)); } else{ Z+=b; } } sort(l.begin(), l.end()); sort(r.begin(), r.end()); priority_queue<int64_t, vector<int64_t>, greater<int64_t>> pq; for(auto x:l){ int a; int64_t b; tie(a,b)=x; pq.push(b); if(a<pq.size()){ pq.pop(); } } while(!pq.empty()){ Z+=pq.top(); pq.pop(); } for(auto x:r){ int a; int64_t b; tie(a,b)=x; pq.push(b); if(a<pq.size()){ pq.pop(); } } while(!pq.empty()){ Z+=pq.top(); pq.pop(); } cout<<Z<<endl; } }