結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー beet
提出日時 2018-11-13 17:47:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 1,212 bytes
コンパイル時間 2,795 ms
コンパイル使用メモリ 226,144 KB
最終ジャッジ日時 2025-01-06 16:35:07
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> l(n);
  for(Int i=0;i<n;i++) cin>>l[i];
  
  vector<Int> cnt(n,0);
  auto sc=[&](Int x){return 50*l[x]+(500*l[x]/(8+2*++cnt[x]));};
  
  Int q;
  cin>>q;
  map<string, Int> lst,sum;
  map<string, vector<Int> > dat;
  for(Int i=0;i<q;i++){
    string s;
    char p;    
    cin>>s>>p;
    if(!dat.count(s)) dat[s]=vector<Int>(n,0);
    lst[s]=i;
    Int add=sc(p-'A');
    sum[s]+=add;
    dat[s][p-'A']=add;
  }

  vector<string> vs;
  for(auto p:lst) vs.emplace_back(p.first);

  auto cmp=
    [&](Int x,Int y)->Int{
      if(sum[vs[x]]!=sum[vs[y]])
        return sum[vs[x]]>sum[vs[y]];
      return lst[vs[x]]<lst[vs[y]];
    };
  
  Int m=vs.size();
  vector<Int> ord(m);
  iota(ord.begin(),ord.end(),0);  
  sort(ord.begin(),ord.end(),cmp);
  
  for(Int i=0;i<m;i++){
    cout<<i+1<<" "<<vs[ord[i]];
    for(Int j=0;j<n;j++) cout<<" "<<dat[vs[ord[i]]][j];
    cout<<" "<<sum[vs[ord[i]]]<<endl;
  }  
  return 0;
}
0