結果
| 問題 |
No.2623 Room Allocation
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2024-02-10 03:02:13 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 53 ms / 2,000 ms |
| コード長 | 659 bytes |
| コンパイル時間 | 2,154 ms |
| コンパイル使用メモリ | 199,064 KB |
| 最終ジャッジ日時 | 2025-02-19 04:30:08 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n,x,y;
cin>>n>>x>>y;
int z=x+y;
vector<ll> P(n);
vector<char> C(n);
rep(i,n) cin>>P[i]>>C[i];
if(z==0){
cout<<0<<endl;
return 0;
}
vector<ll> A(z),B(z);
rep(i,n){
if(C[i]=='A') A[i%z]+=P[i];
else B[i%z]+=P[i];
}
ll ans=0;
vector<ll> D(z);
rep(i,z){
D[i]=A[i]-B[i];
ans+=B[i];
}
sort(ALL(D));
reverse(ALL(D));
rep(i,x) ans+=D[i];
cout<<ans<<endl;
return 0;
}
umezo