結果
| 問題 |
No.2623 Room Allocation
|
| コンテスト | |
| ユーザー |
ぷら
|
| 提出日時 | 2024-02-09 21:35:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 58 ms / 2,000 ms |
| コード長 | 1,235 bytes |
| コンパイル時間 | 1,614 ms |
| コンパイル使用メモリ | 139,784 KB |
| 最終ジャッジ日時 | 2025-02-19 03:21:36 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <string.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, X, Y;
cin >> N >> X >> Y;
vector<pair<long long, long long>> tmp(X + Y);
for (int i = 0; i < N; i++) {
int P;
char c;
cin >> P >> c;
if (c == 'A') {
tmp[i % (X + Y)].first += P;
} else {
tmp[i % (X + Y)].second += P;
}
}
long long ans = 0;
vector<long long> res;
for (int i = 0; i < X + Y; i++) {
ans += tmp[i].first;
res.push_back(tmp[i].second - tmp[i].first);
}
sort(res.rbegin(), res.rend());
for (int i = 0; i < Y; i++) {
ans += res[i];
}
cout << ans << "\n";
}
ぷら