結果
問題 | No.2623 Room Allocation |
ユーザー |
|
提出日時 | 2024-02-09 21:34:24 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 45 ms / 2,000 ms |
コード長 | 435 bytes |
コンパイル時間 | 613 ms |
コンパイル使用メモリ | 69,976 KB |
実行使用メモリ | 9,956 KB |
最終ジャッジ日時 | 2024-09-28 14:45:59 |
合計ジャッジ時間 | 2,556 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include<iostream> #include<algorithm> #include<cassert> using namespace std; int N,X,Y; long x[4<<17],y[4<<17]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N>>X>>Y; for(int i=0;i<N;i++) { int p;char c;cin>>p>>c; if(c=='A')x[i%(X+Y)]+=p; else y[i%(X+Y)]+=p; } long ans=0; for(int i=0;i<X+Y;i++) { ans+=x[i]; y[i]=x[i]-y[i]; } sort(y,y+X+Y); for(int i=0;i<Y;i++)ans-=y[i]; cout<<ans<<endl; }