結果
| 問題 |
No.2623 Room Allocation
|
| コンテスト | |
| ユーザー |
ragna
|
| 提出日時 | 2024-02-09 21:50:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 175 ms / 2,000 ms |
| コード長 | 1,197 bytes |
| コンパイル時間 | 4,359 ms |
| コンパイル使用メモリ | 255,884 KB |
| 最終ジャッジ日時 | 2025-02-19 03:32:49 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace atcoder;
using mint=modint998244353;
using namespace std;
using ll=long long;
using ull=unsigned long long;
#define rep(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrep(i,a,b) for(ll i=(ll)(a-1);i>=(ll)(b);i--)
#define MOD 998244353
//#define MOD 1000000007
#define INF 1e18
#define Pair pair<ll,ll>
//#define PI numbers::pi
//#define E numbers::e
template <typename T> bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
ll n,x,y; cin >> n >> x >> y;
vector<ll> p(n);
vector<char> c(n);
rep(i,0,n) cin >> p[i] >> c[i];
vector<Pair> v(x+y,{0,0});
rep(i,0,n){
if(c[i]=='A') v[i%(x+y)].first+=p[i];
else v[i%(x+y)].second+=p[i];
}
priority_queue<Pair> pque;
rep(i,0,x+y) pque.push({v[i].second-v[i].first,i});
vector<char> w(x+y,'A');
rep(i,0,y){
w[pque.top().second]='B';
pque.pop();
}
ll ans=0;
rep(i,0,x+y){
if(w[i]=='A') ans+=v[i].first;
else ans+=v[i].second;
}
cout << ans << endl;
}
ragna