結果
問題 | No.2623 Room Allocation |
ユーザー | GOTKAKO |
提出日時 | 2024-02-09 21:38:57 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 61 ms / 2,000 ms |
コード長 | 977 bytes |
コンパイル時間 | 2,344 ms |
コンパイル使用メモリ | 213,424 KB |
実行使用メモリ | 20,664 KB |
最終ジャッジ日時 | 2024-09-28 14:54:37 |
合計ジャッジ時間 | 4,001 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N,X,Y; cin >> N >> X >> Y; int room = X+Y; vector<vector<pair<long long,char>>> sepa(room); for(int i=0; i<N; i++){ int p; cin >> p; char c; cin >> c; sepa.at(i%room).push_back({p,c}); } long long answer = 0; vector<long long> A,B; for(auto se : sepa){ long long a = 0,b = 0; for(auto [p,c] : se){ if(c == 'A') a += p; else b += p; } if(a > b) A.push_back(a-b),answer += a; else if(a == b) answer += b; else B.push_back(b-a),answer += b; } sort(A.begin(),A.end()); sort(B.begin(),B.end()); if(A.size() > X){ while(X--) A.pop_back(); for(auto a : A) answer -= a; } if(B.size() > Y){ while(Y--) B.pop_back(); for(auto b : B) answer -= b; } cout << answer << endl; }