結果
問題 | No.449 ゆきこーだーの雨と雪 (4) |
ユーザー | nebukuro09 |
提出日時 | 2016-11-21 20:43:40 |
言語 | D (dmd 2.106.1) |
結果 |
AC
|
実行時間 | 261 ms / 5,000 ms |
コード長 | 2,531 bytes |
コンパイル時間 | 785 ms |
コンパイル使用メモリ | 114,320 KB |
実行使用メモリ | 32,436 KB |
最終ジャッジ日時 | 2023-09-02 22:59:42 |
合計ジャッジ時間 | 12,426 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,372 KB |
testcase_01 | AC | 2 ms
5,100 KB |
testcase_02 | AC | 2 ms
4,372 KB |
testcase_03 | AC | 3 ms
4,372 KB |
testcase_04 | AC | 3 ms
4,368 KB |
testcase_05 | AC | 4 ms
4,368 KB |
testcase_06 | AC | 3 ms
4,372 KB |
testcase_07 | AC | 4 ms
4,368 KB |
testcase_08 | AC | 4 ms
4,368 KB |
testcase_09 | AC | 4 ms
4,368 KB |
testcase_10 | AC | 3 ms
4,368 KB |
testcase_11 | AC | 3 ms
4,368 KB |
testcase_12 | AC | 198 ms
18,408 KB |
testcase_13 | AC | 229 ms
22,680 KB |
testcase_14 | AC | 197 ms
23,484 KB |
testcase_15 | AC | 261 ms
23,620 KB |
testcase_16 | AC | 222 ms
24,032 KB |
testcase_17 | AC | 220 ms
23,736 KB |
testcase_18 | AC | 198 ms
18,140 KB |
testcase_19 | AC | 205 ms
22,188 KB |
testcase_20 | AC | 196 ms
22,396 KB |
testcase_21 | AC | 222 ms
23,368 KB |
testcase_22 | AC | 234 ms
22,712 KB |
testcase_23 | AC | 194 ms
18,880 KB |
testcase_24 | AC | 202 ms
23,104 KB |
testcase_25 | AC | 170 ms
20,100 KB |
testcase_26 | AC | 153 ms
17,540 KB |
testcase_27 | AC | 226 ms
23,988 KB |
testcase_28 | AC | 227 ms
22,964 KB |
testcase_29 | AC | 203 ms
21,912 KB |
testcase_30 | AC | 253 ms
24,452 KB |
testcase_31 | AC | 241 ms
22,708 KB |
testcase_32 | AC | 195 ms
22,180 KB |
testcase_33 | AC | 212 ms
22,440 KB |
testcase_34 | AC | 178 ms
19,632 KB |
testcase_35 | AC | 246 ms
24,260 KB |
testcase_36 | AC | 176 ms
18,076 KB |
testcase_37 | AC | 193 ms
31,924 KB |
testcase_38 | AC | 172 ms
28,344 KB |
testcase_39 | AC | 164 ms
27,252 KB |
testcase_40 | AC | 162 ms
27,040 KB |
testcase_41 | AC | 212 ms
28,044 KB |
testcase_42 | AC | 211 ms
28,100 KB |
testcase_43 | AC | 179 ms
18,348 KB |
testcase_44 | AC | 221 ms
18,876 KB |
testcase_45 | AC | 203 ms
32,436 KB |
コンパイルメッセージ
Main.d(57): Deprecation: use `{ }` for an empty statement, not `;`
ソースコード
import std.stdio; import std.array; import std.string; import std.conv; import std.algorithm; import std.typecons; import std.range; import std.random; import std.math; import std.container; class SegmentTree { int[] table; int N, table_size; this(int n) { N = n; table_size = 1; while (table_size < n) table_size *= 2; table_size *= 2; table = new int[](table_size); } void add(int pos, int num) { add_rec(0, 0, table_size/2-1, pos, num); } void add_rec(int i, int left, int right, int pos, int num) { table[i] += num; if (left == right) return; auto mid = (left + right) / 2; if (pos <= mid) add_rec(i*2+1, left, mid, pos, num); else add_rec(i*2+2, mid+1, right, pos, num); } int sum(int pl, int pr) { return sum_rec(0, pl, pr, 0, table_size/2-1); } int sum_rec(int i, int pl, int pr, int left, int right) { if (pl > right || pr < left) return 0; else if (pl <= left && right <= pr) return table[i]; else return sum_rec(i*2+1, pl, pr, left, (left+right)/2) + sum_rec(i*2+2, pl, pr, (left+right)/2+1, right); } } void main() { auto score(int a, int b) {return 50*a + 500*a/(8+2*b);}; alias Tuple!(int, "score", int, "order") Point; auto N = readln.chomp.to!int; auto L = readln.split.map!(to!int); Point[string] participants; Point[] points; auto ACed = new int[](N); auto T = readln.chomp.to!int; auto NP = new Tuple!(string, int, int)[](T); foreach (i; 0..T) { auto input = readln.split; if (input[1] == "?") { NP[i] = tuple(input[0], -1, -1); continue; } auto name = input[0]; auto prob = input[1][0].to!int - 'A'.to!int; ACed[prob] += 1; if (name in participants) participants[name] = Point(participants[name].score + score(L[prob], ACed[prob]), i); else participants[name] = Point(score(L[prob], ACed[prob]), i); points ~= Point(-participants[name].score, i); NP[i] = tuple(name, participants[name].score, i); } points.sort(); int[Point] ranks; foreach (i, p; points.enumerate) ranks[Point(-p.score, p.order)] = i.to!int; auto sg = new SegmentTree(100000); int[string] last; foreach (i; 0..T) { if (NP[i][2] == -1) { writeln(sg.sum(0, last[NP[i][0]])); } else { auto name = NP[i][0]; auto rank = ranks[Point(NP[i][1], NP[i][2])]; if (name in last) sg.add(last[name], -1); last[name] = rank; sg.add(rank, 1); } } }