結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー koyoprokoyopro
提出日時 2019-12-19 00:58:23
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 2,394 bytes
コンパイル時間 2,306 ms
コンパイル使用メモリ 171,356 KB
実行使用メモリ 10,076 KB
最終ジャッジ日時 2023-09-21 04:36:34
合計ジャッジ時間 4,440 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 6 ms
4,376 KB
testcase_04 AC 5 ms
4,376 KB
testcase_05 AC 17 ms
4,508 KB
testcase_06 AC 40 ms
7,844 KB
testcase_07 AC 15 ms
4,828 KB
testcase_08 AC 20 ms
5,552 KB
testcase_09 AC 33 ms
6,500 KB
testcase_10 AC 5 ms
4,376 KB
testcase_11 AC 8 ms
4,380 KB
testcase_12 AC 12 ms
4,504 KB
testcase_13 AC 27 ms
5,936 KB
testcase_14 AC 34 ms
6,468 KB
testcase_15 AC 9 ms
4,380 KB
testcase_16 AC 8 ms
4,380 KB
testcase_17 AC 7 ms
4,380 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 56 ms
10,076 KB
testcase_20 AC 38 ms
7,032 KB
testcase_21 AC 10 ms
4,380 KB
testcase_22 AC 7 ms
4,376 KB
testcase_23 AC 11 ms
4,404 KB
testcase_24 AC 34 ms
7,500 KB
testcase_25 AC 50 ms
9,160 KB
testcase_26 AC 18 ms
5,304 KB
testcase_27 AC 16 ms
5,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define array2(type, x, y) array<array<type, y>, x>
#define vector2(type) vector<vector<type> >
#define out(...) printf(__VA_ARGS__)

typedef pair<int, int> pos;
int pos::*x = &pos::first;
int pos::*y = &pos::second;

int dxy[] = {0, 1, 0, -1, 0};

/*================================*/

int N, T;

signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    
    cin >> N;
    int L[N];
    REP(i, N) cin >> L[i];
    
    int AC[N];
    vector< map<string, int> > POINTS(N);
    REP(i, N) AC[i] = 0;
    

    map<string, pos> MAP;
    cin >> T;
    string name;
    char C;
    REP(i, T) {
        cin >> name >> C;
        // 50×★の数+50×★の数 / (0.8+ 0.2×ACの順位)
        int problem = C - 'A';
        int star = L[problem];
        AC[problem]++;
        int score = floor(50 * star + (50 * star) / (0.8 + 0.2 * AC[problem]));
        if (MAP.count(name) == 0) MAP[name] = *new pos(0, 0);
        MAP[name].first += score;
        MAP[name].second = i; // order
        POINTS[problem][name] = score;
    }
    
    struct User
    {
        std::string name;
        int score;
        int last;
    
        User(string _name, int _score, int _last)
        {
            name = _name;
            score = _score;
            last = _last;
        }
    };

    auto comp = [](User a, User b) { return a.score < b.score || (a.score == b.score && a.last > b.last); };
    priority_queue<User, std::vector<User>, decltype(comp)> que(comp);
    
    int rank = 1;
    for (auto const& item: MAP)
    {
        User *u = new User(item.first, item.second.first, item.second.second);
        que.push(*u);
    }
    while (!que.empty()) {
        User u = que.top();
        que.pop();
        // 順位, 名前, 各問題のスコア, スコアの合計点
        cout << rank++ << " " << u.name << " ";
        REP(i, N) cout << POINTS[i][u.name] << " ";
        cout << u.score << endl;
    }
    
    return 0;
}
0