結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー けーむ
提出日時 2020-08-14 15:09:29
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 1,918 bytes
コンパイル時間 2,033 ms
コンパイル使用メモリ 184,448 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-10 11:58:42
合計ジャッジ時間 3,650 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

struct S {
    string name;
    vector<ll> score;
    vector<bool> clear;
    ll tot, upd;
    
    bool operator<(const S &b) const {
        if (tot != b.tot) return tot > b.tot;
        return upd < b.upd;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> l(n);
    rep(i, n) cin >> l[i];
    vector<ll> cnt(n, 0);
    ll m;
    cin >> m;
    vector<S> users;
    rep(i, m) {
        string name;
        char prob;
        cin >> name >> prob;
        ll id = prob - 'A';
        ll user = -1;
        rep(j, sz(users)) {
            if (users[j].name == name) {
                user = j;
                break;
            }
        }
        if (user == -1) {
            user = sz(users);
            users.push_back((S){name, vector<ll>(n, 0), vector<bool>(n, false), 0, LONG_LONG_MIN});
        }
        if (!users[user].clear[id]) {
            cnt[id]++;
            users[user].clear[id] = true;
            users[user].score[id] = 50 * l[id] + 50 * l[id] / (0.8 + 0.2 * cnt[id]);
            users[user].upd = i;
            users[user].tot += users[user].score[id];
        }
    }
    sort(all(users));
    rep(i, sz(users)) {
        printf("%lld %s", i + 1, users[i].name.c_str());
        rep(j, n) printf(" %lld", users[i].score[j]);
        printf(" %lld\n", users[i].tot);
    }
    return 0;
}
0