結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー MisterMister
提出日時 2020-05-29 17:52:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 1,612 bytes
コンパイル時間 1,473 ms
コンパイル使用メモリ 105,612 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 15:19:41
合計ジャッジ時間 2,916 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 7 ms
6,944 KB
testcase_06 AC 11 ms
6,944 KB
testcase_07 AC 6 ms
6,944 KB
testcase_08 AC 7 ms
6,944 KB
testcase_09 AC 10 ms
6,940 KB
testcase_10 AC 3 ms
6,944 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 4 ms
6,940 KB
testcase_13 AC 8 ms
6,940 KB
testcase_14 AC 11 ms
6,944 KB
testcase_15 AC 4 ms
6,940 KB
testcase_16 AC 3 ms
6,944 KB
testcase_17 AC 3 ms
6,940 KB
testcase_18 AC 3 ms
6,944 KB
testcase_19 AC 14 ms
6,940 KB
testcase_20 AC 11 ms
6,944 KB
testcase_21 AC 4 ms
6,944 KB
testcase_22 AC 3 ms
6,940 KB
testcase_23 AC 4 ms
6,940 KB
testcase_24 AC 9 ms
6,944 KB
testcase_25 AC 12 ms
6,940 KB
testcase_26 AC 6 ms
6,944 KB
testcase_27 AC 5 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>

void solve() {
    int n;
    std::cin >> n;

    std::vector<int> xs(n);
    for (auto& x : xs) std::cin >> x;

    std::map<std::string, std::vector<int>> scores;
    std::vector<int> rank(n, 1);

    int q;
    std::cin >> q;

    for (int t = 0; t < q; ++t) {
        std::string s;
        std::cin >> s;

        if (!scores.count(s)) {
            scores[s] = std::vector<int>(n + 1, 0);
        }

        auto& score = scores[s];

        char c;
        std::cin >> c;
        int id = c - 'A';

        auto x = xs[id];
        auto r = rank[id]++;
        score[id] = x * 50 + x * 500 / (r * 2 + 8);
        score.back() = t;
    }

    std::vector<std::pair<std::string, std::vector<int>>> ans(scores.begin(), scores.end());
    std::sort(ans.begin(), ans.end(),
              [](const auto& p, const auto& q) {
                  auto psum = std::accumulate(p.second.begin(), --p.second.end(), 0);
                  auto qsum = std::accumulate(q.second.begin(), --q.second.end(), 0);
                  if (psum != qsum) return psum > qsum;
                  return p.second.back() < q.second.back();
              });

    int id = 1;
    for (auto p : ans) {
        std::cout << id++ << " " << p.first;
        p.second.back() = std::accumulate(p.second.begin(), --p.second.end(), 0);
        for (auto s : p.second) std::cout << " " << s;
        std::cout << "\n";
    }
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0