結果
問題 | No.449 ゆきこーだーの雨と雪 (4) |
ユーザー | りあん |
提出日時 | 2016-10-26 19:26:29 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 4,171 bytes |
コンパイル時間 | 1,043 ms |
コンパイル使用メモリ | 116,036 KB |
実行使用メモリ | 66,452 KB |
最終ジャッジ日時 | 2024-09-22 09:23:54 |
合計ジャッジ時間 | 122,760 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
28,064 KB |
testcase_01 | AC | 43 ms
29,748 KB |
testcase_02 | AC | 43 ms
27,552 KB |
testcase_03 | AC | 58 ms
27,684 KB |
testcase_04 | AC | 55 ms
27,940 KB |
testcase_05 | AC | 58 ms
28,064 KB |
testcase_06 | AC | 54 ms
29,628 KB |
testcase_07 | AC | 56 ms
28,068 KB |
testcase_08 | AC | 54 ms
27,564 KB |
testcase_09 | AC | 56 ms
27,808 KB |
testcase_10 | AC | 54 ms
29,992 KB |
testcase_11 | AC | 53 ms
27,824 KB |
testcase_12 | AC | 2,482 ms
53,108 KB |
testcase_13 | AC | 3,997 ms
54,852 KB |
testcase_14 | AC | 3,226 ms
55,024 KB |
testcase_15 | AC | 4,289 ms
57,256 KB |
testcase_16 | AC | 3,542 ms
55,556 KB |
testcase_17 | AC | 3,557 ms
55,484 KB |
testcase_18 | AC | 2,487 ms
53,104 KB |
testcase_19 | AC | 3,219 ms
55,228 KB |
testcase_20 | AC | 3,220 ms
57,192 KB |
testcase_21 | AC | 3,914 ms
56,836 KB |
testcase_22 | AC | 3,990 ms
57,012 KB |
testcase_23 | AC | 2,477 ms
51,044 KB |
testcase_24 | AC | 3,626 ms
55,860 KB |
testcase_25 | AC | 2,088 ms
49,776 KB |
testcase_26 | AC | 1,687 ms
50,020 KB |
testcase_27 | AC | 3,912 ms
57,032 KB |
testcase_28 | AC | 3,954 ms
56,840 KB |
testcase_29 | AC | 3,288 ms
54,972 KB |
testcase_30 | AC | 4,310 ms
59,064 KB |
testcase_31 | AC | 3,967 ms
57,036 KB |
testcase_32 | AC | 3,182 ms
57,060 KB |
testcase_33 | AC | 3,571 ms
55,952 KB |
testcase_34 | AC | 2,094 ms
50,428 KB |
testcase_35 | AC | 4,361 ms
59,460 KB |
testcase_36 | AC | 2,083 ms
50,300 KB |
testcase_37 | TLE | - |
testcase_38 | AC | 3,432 ms
57,660 KB |
testcase_39 | AC | 2,912 ms
59,448 KB |
testcase_40 | AC | 3,491 ms
57,520 KB |
testcase_41 | AC | 4,905 ms
57,764 KB |
testcase_42 | AC | 4,910 ms
57,576 KB |
testcase_43 | AC | 1,989 ms
52,544 KB |
testcase_44 | AC | 3,087 ms
57,428 KB |
testcase_45 | TLE | - |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; class contestant { static int n; static int[] lev; static int[] counts; public string name; public int sum = 0; public long uniscore = 0; public long preuni = 0; public static void init(int _n, int[] _lev) { n = _n; lev = _lev; counts = new int[n]; } public contestant(string name) { this.name = name; } public long submit(char c, int t) { int p = c - 'A'; sum += lev[p] * 50 + (int)(lev[p] * 50 / (1 + 0.2 * counts[p]) + 1e-9); ++counts[p]; preuni = uniscore; return uniscore = (long)sum * 100000 - t; } } class Program { static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; static void Main() { var sc = new Scan(); int n = sc.Int; var lev = sc.IntArr; contestant.init(n, lev); var id = new SortedDictionary<string, int>(); var lis = new List<contestant>(); var uniscore = new List<long>(); var zip = new SortedDictionary<long, int>(); int t = sc.Int; var np = new string[t][]; var unis = new long[t]; var preuni = new long[t]; uniscore.Add(0); for (int i = 0; i < t; i++) { np[i] = sc.StrArr; if (np[i][1] == "?") { unis[i] = lis[id[np[i][0]]].uniscore; continue; } if (!id.ContainsKey(np[i][0])) { id.Add(np[i][0], lis.Count); lis.Add(new contestant(np[i][0])); } else { preuni[i] = lis[id[np[i][0]]].uniscore; } unis[i] = lis[id[np[i][0]]].submit(np[i][1][0], i); uniscore.Add(unis[i]); } uniscore.Sort(); int lim = uniscore.Count; for (int i = 0; i < lim; i++) { zip.Add(uniscore[i], i + 1); } var sg = new Segtree<int>(lim + 1, (i, j) => i + j, 0); for (int i = 0; i < t; ++i) { if (np[i][1] == "?") { sw.WriteLine(sg.run(zip[unis[i]], lim + 1)); continue; } sg.update(zip[preuni[i]], 0); sg.update(zip[unis[i]], 1); } sw.Flush(); } static void Prt<T>(IEnumerable<T> a) => sw.WriteLine(string.Join(" ", a)); } class Scan { public int Int => int.Parse(Str); public long Long => long.Parse(Str); public double Double => double.Parse(Str); public string Str => Console.ReadLine().Trim(); public int[] IntArr => StrArr.Select(int.Parse).ToArray(); public long[] LongArr => StrArr.Select(long.Parse).ToArray(); public double[] DoubleArr => StrArr.Select(double.Parse).ToArray(); public string[] StrArr => Str.Split(); } class Segtree<T> { int n, s, t; T[] tr; Func<T, T, T> f; T exnum; public Segtree(int m, Func<T, T, T> f, T ex) { this.f = f; this.exnum = ex; n = 1; while (n < m) n <<= 1; tr = new T[(n << 1) - 1]; for (int i = 0; i < tr.Length; i++) tr[i] = ex; } public Segtree(int m, T ini, Func<T, T, T> f, T ex) : this(m, f, ex) { for (int i = 0; i < m; ++i) tr[i + n - 1] = ini; all_update(); } public void assign(int j, T x) => tr[j + n - 1] = x; public void update(int j, T x) { int i = j + n - 1; tr[i] = x; while (i > 0) { i = i - 1 >> 1; tr[i] = f(tr[i << 1 | 1], tr[i + 1 << 1]); } } public void all_update() { for (int i = n - 2; i >= 0; i--) tr[i] = f(tr[i << 1 | 1], tr[i + 1 << 1]); } public T look(int i) => tr[i + n - 1]; // [s, t) public T run(int s, int t) { this.s = s; this.t = t; return q(0, 0, n); } T q(int k, int l, int r) => r <= s || t <= l ? exnum : s <= l && r <= t ? tr[k] : f(q(k << 1 | 1, l, l + r >> 1), q(k + 1 << 1, l + r >> 1, r)); }