結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー 👑 hos.lyrichos.lyric
提出日時 2019-06-11 02:03:11
言語 D
(dmd 2.105.2)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 2,458 bytes
コンパイル時間 9,556 ms
コンパイル使用メモリ 683,216 KB
実行使用メモリ 7,836 KB
最終ジャッジ日時 2023-09-04 01:37:17
合計ジャッジ時間 12,136 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 8 ms
4,920 KB
testcase_04 AC 7 ms
4,748 KB
testcase_05 AC 20 ms
5,240 KB
testcase_06 AC 41 ms
7,552 KB
testcase_07 AC 18 ms
5,192 KB
testcase_08 AC 22 ms
5,260 KB
testcase_09 AC 35 ms
7,700 KB
testcase_10 AC 7 ms
4,596 KB
testcase_11 AC 10 ms
5,128 KB
testcase_12 AC 14 ms
4,872 KB
testcase_13 AC 29 ms
5,332 KB
testcase_14 AC 36 ms
5,776 KB
testcase_15 AC 11 ms
4,976 KB
testcase_16 AC 11 ms
4,640 KB
testcase_17 AC 9 ms
4,864 KB
testcase_18 AC 4 ms
4,460 KB
testcase_19 AC 56 ms
7,836 KB
testcase_20 AC 39 ms
5,820 KB
testcase_21 AC 12 ms
4,828 KB
testcase_22 AC 9 ms
5,032 KB
testcase_23 AC 15 ms
5,248 KB
testcase_24 AC 37 ms
5,248 KB
testcase_25 AC 50 ms
5,760 KB
testcase_26 AC 22 ms
5,196 KB
testcase_27 AC 19 ms
5,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


int N;
real[] L;
int T;
string[] S, P;

class Contestant {
  string name;
  int[] scores;
  int sum;
  int last;
}

void main() {
  try {
    for (; ; ) {
      N = readInt();
      L = new real[N];
      foreach (j; 0 .. N) {
        L[j] = readReal();
      }
      T = readInt();
      S = new string[T];
      P = new string[T];
      foreach (t; 0 .. T) {
        S[t] = readToken();
        P[t] = readToken();
      }
      
      const names = S.dup.sort.uniq.array;
      const m = cast(int)(names.length);
      auto cs = new Contestant[m];
      foreach (i; 0 .. m) {
        cs[i] = new Contestant();
        cs[i].name = names[i];
        cs[i].scores = new int[N];
      }
      
      auto cnt = new int[N];
      foreach (t; 0 .. T) {
        const i = names.lowerBound(S[t]);
        const j = P[t][0] - 'A';
        ++cnt[j];
        cs[i].scores[j] = cast(int)(50 * L[j] + 5 * 50 * L[j] / (4 + cnt[j]));
        cs[i].last = t;
      }
      
      foreach (i; 0 .. m) {
        cs[i].sum = cs[i].scores.sum;
      }
      cs.sort!((a, b) => ((a.sum != b.sum) ? (a.sum > b.sum) : (a.last < b.last)));
      foreach (i; 0 .. m) {
        writefln("%s %s %s %s", i + 1, cs[i].name, cs[i].scores.to!string.replaceAll(regex(`[\[\],]`), ""), cs[i].sum);
      }
    }
  } catch (EOFException e) {
  }
}
0