結果

問題 No.2590 100000 Days of Christmas
ユーザー 👑 kakel-sankakel-san
提出日時 2023-12-18 23:38:30
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 411 ms / 2,000 ms
コード長 2,221 bytes
コンパイル時間 8,352 ms
コンパイル使用メモリ 158,884 KB
実行使用メモリ 199,352 KB
最終ジャッジ日時 2023-12-18 23:38:44
合計ジャッジ時間 13,141 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
32,932 KB
testcase_01 AC 82 ms
32,932 KB
testcase_02 AC 80 ms
32,804 KB
testcase_03 AC 80 ms
32,804 KB
testcase_04 AC 81 ms
32,804 KB
testcase_05 AC 83 ms
32,932 KB
testcase_06 AC 364 ms
50,176 KB
testcase_07 AC 106 ms
38,180 KB
testcase_08 AC 386 ms
51,948 KB
testcase_09 AC 110 ms
37,796 KB
testcase_10 AC 82 ms
32,932 KB
testcase_11 AC 81 ms
32,932 KB
testcase_12 AC 82 ms
32,932 KB
testcase_13 AC 83 ms
32,932 KB
testcase_14 AC 83 ms
32,932 KB
testcase_15 AC 82 ms
32,932 KB
testcase_16 AC 83 ms
32,932 KB
testcase_17 AC 81 ms
32,932 KB
testcase_18 AC 81 ms
32,932 KB
testcase_19 AC 82 ms
32,932 KB
testcase_20 AC 385 ms
51,832 KB
testcase_21 AC 411 ms
51,928 KB
testcase_22 AC 368 ms
51,200 KB
testcase_23 AC 385 ms
199,352 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (113 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var dic = new Dictionary<string, long>();
        for (var i = 0; i < n; ++i)
        {
            var s = ReadLine();
            if (dic.ContainsKey(s)) dic[s] += (i + 1L) * (n - i);
            else dic[s] = (i + 1L) * (n - i);
        }
        var names = dic.Keys.ToList();
        names.Sort(StringComparer.Ordinal);
        foreach (var p in names)
        {
            WriteLine($"{dic[p]} {p}");
        }
    }
    class FenwickTree
    {
        int size;
        long[] tree;
        public FenwickTree(int size)
        {
            this.size = size;
            tree = new long[size + 2];
        }
        public void Add(int index, long value)
        {
            ++index;
            for (var x = index; x <= size; x += (x & -x)) tree[x] += value;
        }
        /// <summary>先頭からindexまでの和(include index)</summary>
        public long Sum(int index)
        {
            if (index < 0) return 0;
            ++index;
            var sum = 0L;
            for (var x = index; x > 0; x -= (x & -x)) sum += tree[x];
            return sum;
        }
        /// <summary>Sum(x) >= value となる最小のxを求める</summary>
        // 各要素は非負であること
        public int LowerBound(long value)
        {
            if (value < 0) return -1;
            var x = 0;
            var b = 1;
            while (b * 2 <= size) b <<= 1;
            for (var k = b; k > 0; k >>= 1)
            {
                if (x + k <= size && tree[x + k] < value)
                {
                    value -= tree[x + k];
                    x += k;
                }
            }
            return x;
        }
        public long Get(int index)
        {
            return index == 0 ? Sum(0) : (Sum(index) - Sum(index - 1));
        }
    }
}
0