結果

問題 No.118 門松列(2)
ユーザー eitahoeitaho
提出日時 2015-06-13 17:17:59
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 66 ms / 5,000 ms
コード長 2,582 bytes
コンパイル時間 1,054 ms
コンパイル使用メモリ 112,832 KB
実行使用メモリ 29,184 KB
最終ジャッジ日時 2024-04-17 12:58:33
合計ジャッジ時間 3,322 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
20,224 KB
testcase_01 AC 65 ms
28,928 KB
testcase_02 AC 65 ms
28,928 KB
testcase_03 AC 66 ms
29,184 KB
testcase_04 AC 65 ms
28,800 KB
testcase_05 AC 65 ms
28,928 KB
testcase_06 AC 29 ms
18,944 KB
testcase_07 AC 29 ms
19,200 KB
testcase_08 AC 29 ms
19,200 KB
testcase_09 AC 64 ms
27,636 KB
testcase_10 AC 39 ms
21,632 KB
testcase_11 AC 42 ms
22,016 KB
testcase_12 AC 38 ms
20,992 KB
testcase_13 AC 36 ms
20,608 KB
testcase_14 AC 63 ms
27,384 KB
testcase_15 AC 34 ms
19,584 KB
testcase_16 AC 50 ms
24,448 KB
testcase_17 AC 35 ms
20,224 KB
testcase_18 AC 41 ms
21,888 KB
testcase_19 AC 48 ms
23,808 KB
testcase_20 AC 49 ms
24,192 KB
testcase_21 AC 57 ms
26,348 KB
testcase_22 AC 40 ms
21,888 KB
testcase_23 AC 56 ms
25,472 KB
testcase_24 AC 43 ms
22,272 KB
testcase_25 AC 47 ms
23,680 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

class Program
{
    static readonly int MaxElement = 100;
    static readonly int Mod = (int)1e9 + 7;

    public void Solve()
    {
        int N = Reader.Int();
        var A = Reader.IntArray(N);
        long[] count = new long[MaxElement + 1];
        foreach (var a in A) count[a]++;
        long[] sum = new long[count.Length];
        for (int i = 1; i < sum.Length; i++) 
            sum[i] = (sum[i - 1] + count[i]) % Mod;

        long ans = 0;
        for (int i = 1; i < MaxElement; i++)
        {
            ans += count[i] * sum[i - 1] % Mod * (sum[MaxElement] - sum[i]);
            ans %= Mod;
        }

        Console.WriteLine(ans);
    }

}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    private static TextReader reader = Console.In;
    private static readonly char[] separator = { ' ' };
    private static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    private static string[] A = new string[0];
    private static int i;
    private static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Enu.Range(0, N).Select(i => Int()).ToArray(); }
    public static int[][] IntTable(int H) { return Enu.Range(0, H).Select(i => IntLine()).ToArray(); }
    public static string[] StringArray(int N) { return Enu.Range(0, N).Select(i => Line()).ToArray(); }
    public static string Line() { return reader.ReadLine().Trim(); }
    private static string[] Split(string s) { return s.Split(separator, op); }
    private static string Next() { CheckNext(); return A[i++]; }
    private static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}
0