結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー かにかに
提出日時 2017-03-31 22:15:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 1,657 bytes
コンパイル時間 2,679 ms
コンパイル使用メモリ 195,396 KB
実行使用メモリ 4,744 KB
最終ジャッジ日時 2023-09-21 10:46:59
合計ジャッジ時間 4,865 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 6 ms
4,376 KB
testcase_04 AC 5 ms
4,376 KB
testcase_05 AC 23 ms
4,524 KB
testcase_06 AC 29 ms
4,592 KB
testcase_07 AC 12 ms
4,380 KB
testcase_08 AC 17 ms
4,376 KB
testcase_09 AC 30 ms
4,544 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 5 ms
4,380 KB
testcase_12 AC 11 ms
4,380 KB
testcase_13 AC 26 ms
4,376 KB
testcase_14 AC 32 ms
4,744 KB
testcase_15 AC 7 ms
4,376 KB
testcase_16 AC 7 ms
4,376 KB
testcase_17 AC 6 ms
4,376 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 35 ms
4,528 KB
testcase_20 AC 33 ms
4,640 KB
testcase_21 AC 8 ms
4,380 KB
testcase_22 AC 7 ms
4,380 KB
testcase_23 AC 9 ms
4,376 KB
testcase_24 AC 22 ms
4,380 KB
testcase_25 AC 30 ms
4,380 KB
testcase_26 AC 12 ms
4,376 KB
testcase_27 AC 11 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define mp(a,b) make_pair(a,b)
using namespace std; typedef long long ll; typedef unsigned long long ull; int dx[] = { 1, -1 , 0 , 0 }; int dy[] = { 0,  0,  1, -1 };

bool comp(pair<pair<int,int>,string> p1,pair<pair<int,int>,string> p2){
  if(p1.first.first == p2.first.first){
    return p1.first.second > p2.first.second;
  }else{
    return p1.first.first < p2.first.first;
  }
}

void solve() {
  int n;
  cin >> n;
  vi l(n), ac(n, 1);
  map<string, vector<int> > names;
  map<string,int> last;
  rep(i, n)cin >> l[i];
  int t;
  cin >> t;
  rep(i, t) {
    string name;
    char mon;
    cin >> name >> mon;
    int tmp = mon - 'A';
    if (names.find(name) == names.end()) {
      rep(j, 26) {
	names[name].push_back(0);
      }
    }
    names[name][tmp] = (int)(l[tmp]*50 + (double)(50*l[tmp] / (0.8 + (0.2*ac[tmp]))));
    last[name] = i+1;
    ac[tmp]++;
  }
  vector<pair<pair<int, int>,string > > v;
  for (map<string,vector<int> >::iterator it = names.begin(); it != names.end(); it++) {
    int sum = 0;
    rep(i, 26) {
      sum += it->second[i];
    }
    v.push_back(make_pair(make_pair(sum, last[it->first]),it->first));
  }
  sort(v.begin(), v.end(),comp);
  reverse(v.begin(),v.end());
  rep(i, v.size()) {
    cout << i + 1 << " " << v[i].second << " ";
    rep(j, n) {
      cout << names[v[i].second][j] << " ";
    }
    cout << v[i].first.first << endl;
  }
}

int main() {
  solve();
  return 0;
}
0