結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー beetbeet
提出日時 2018-11-13 17:47:59
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 1,212 bytes
コンパイル時間 3,592 ms
コンパイル使用メモリ 233,072 KB
実行使用メモリ 4,960 KB
最終ジャッジ日時 2023-08-26 00:51:05
合計ジャッジ時間 5,778 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 6 ms
4,376 KB
testcase_04 AC 6 ms
4,380 KB
testcase_05 AC 40 ms
4,460 KB
testcase_06 AC 47 ms
4,620 KB
testcase_07 AC 17 ms
4,376 KB
testcase_08 AC 27 ms
4,376 KB
testcase_09 AC 52 ms
4,956 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 7 ms
4,380 KB
testcase_12 AC 15 ms
4,376 KB
testcase_13 AC 44 ms
4,624 KB
testcase_14 AC 57 ms
4,960 KB
testcase_15 AC 8 ms
4,380 KB
testcase_16 AC 10 ms
4,376 KB
testcase_17 AC 7 ms
4,384 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 57 ms
4,928 KB
testcase_20 AC 57 ms
4,812 KB
testcase_21 AC 11 ms
4,380 KB
testcase_22 AC 9 ms
4,376 KB
testcase_23 AC 10 ms
4,380 KB
testcase_24 AC 32 ms
4,376 KB
testcase_25 AC 46 ms
4,708 KB
testcase_26 AC 17 ms
4,376 KB
testcase_27 AC 15 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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