結果

問題 No.2623 Room Allocation
ユーザー ぷらぷら
提出日時 2024-02-09 21:35:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 1,235 bytes
コンパイル時間 1,361 ms
コンパイル使用メモリ 144,820 KB
実行使用メモリ 14,416 KB
最終ジャッジ日時 2024-02-09 21:36:05
合計ジャッジ時間 3,337 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 20 ms
6,676 KB
testcase_07 AC 20 ms
6,676 KB
testcase_08 AC 20 ms
6,676 KB
testcase_09 AC 19 ms
6,676 KB
testcase_10 AC 15 ms
14,412 KB
testcase_11 AC 14 ms
14,412 KB
testcase_12 AC 8 ms
8,596 KB
testcase_13 AC 9 ms
8,596 KB
testcase_14 AC 47 ms
14,416 KB
testcase_15 AC 29 ms
6,676 KB
testcase_16 AC 8 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 29 ms
6,676 KB
testcase_19 AC 27 ms
6,676 KB
testcase_20 AC 29 ms
6,676 KB
testcase_21 AC 30 ms
6,676 KB
testcase_22 AC 22 ms
6,676 KB
testcase_23 AC 14 ms
6,676 KB
testcase_24 AC 29 ms
6,676 KB
testcase_25 AC 23 ms
6,676 KB
testcase_26 AC 4 ms
6,676 KB
testcase_27 AC 56 ms
13,236 KB
testcase_28 AC 25 ms
8,820 KB
testcase_29 AC 18 ms
8,648 KB
testcase_30 AC 52 ms
9,420 KB
testcase_31 AC 6 ms
6,676 KB
testcase_32 AC 14 ms
12,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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";
}
0