結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー Nasatame
提出日時 2016-11-18 23:40:32
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 1,556 bytes
コンパイル時間 1,302 ms
コンパイル使用メモリ 91,596 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-26 08:44:12
合計ジャッジ時間 2,405 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <stdexcept>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int formula(int star,int n){
    return 50*star + 50*star/(0.8 + 0.2 * n);
}

class par{
public:
    string name;
    int updata;
    int p;
    
    par(string n,int u,int point){
        name = n;
        updata = u;
        p = point;
    }
};

int main(void){
    // Here your code !
    int n;
    cin >> n;
    vector<int> star(n);
    vector<int> ac(n,1);
    for(int i = 0; i < n; i++) cin >> star[i];
    
    map<string,vector<int>> number;
    map<string,int> updata;
    
    int t;
    cin >> t;
    
    for(int i = 0; i < t; i++){
        string s;
        char a;
        cin >> s;
        cin >> a;
        a -= 'A';
        if(number[s].size() == 0) number[s] = vector<int>(n,0);
        number[s][a] = formula(star[a],ac[a]++);
        updata[s] = i;
    }
    
    //最終順位付け
    
    vector<par> rank;
    
    for( auto i = number.begin() ; i != number.end() ; i++){
        int tmp = 0;
        for(int j = 0; j < n; j++)
            tmp += i->second[j];
        
        rank.push_back(par(i->first,updata[i->first],tmp));
    }
    
    sort(rank.begin(),rank.end(),[](const par& a,const par& b){
        return a.p == b.p ? a.updata < b.updata : a.p > b.p;
    });
    
    for(int i = 0; i < rank.size(); i++){
        cout << i+1 << " " << rank[i].name << " ";
        for(int j = 0; j < n; j++)cout << number[rank[i].name][j] << " ";
        cout << rank[i].p << endl;
    }
    
}
0