提出 #70420180


ソースコード 拡げる

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

#pragma warning disable CS8603, CS8604, CS8602


namespace ProblemC
{
    internal class TEST
    {
        public static void Main()
        {
            Sol mySol = new Sol();
            mySol.Solve();
        }
    }

    internal class Sol
    {
        public void Solve()
        {
            var di = new Dictionary<long, long>();
            foreach(var n in A){
                if (!di.ContainsKey(n)) di.Add(n, 0);
                di[n]++;
            }

            long tot = 0;
            foreach(var k in di.Keys){
                if (di[k] < 2) continue;
                long c = di[k] * (di[k] - 1) / 2 * (N - di[k]);
                tot += c;
            }

            Console.WriteLine(tot);

        }
        int N;
        long[] A;
        public Sol()
        {
            N = ri();
            A = rla();
        }

        static String rs() { return Console.ReadLine(); }
        static int ri() { return int.Parse(Console.ReadLine()); }
        static long rl() { return long.Parse(Console.ReadLine()); }
        static double rd() { return double.Parse(Console.ReadLine()); }
        static String[] rsa(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ria(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] rla(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] rda(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static T[] mka<T>(int n, T ini) { T[] ret = new T[n]; for (int i = 0; i < n; i++) ret[i] = ini; return ret; }
        static T[][] mka<T>(int n, int m, T ini) { T[][] ret = new T[n][]; for (int i = 0; i < n; i++) ret[i] = mka(m, ini); return ret; }
        static T[][][] mka<T>(int n, int m, int l, T ini) { T[][][] ret = new T[n][][]; for (int i = 0; i < n; i++) ret[i] = mka(m, l, ini); return ret; }
        static T[][][][] mka<T>(int n, int m, int l, int k, T ini) { T[][][][] ret = new T[n][][][]; for (int i = 0; i < n; i++) ret[i] = mka(m, l, k, ini); return ret; }
        static T[] mka<T>(int n) where T : new() { T[] ret = new T[n]; for (int i = 0; i < n; i++) ret[i] = new T(); return ret; }
        static T[][] mka<T>(int n, int m) where T : new() { T[][] ret = new T[n][]; for (int i = 0; i < n; i++) ret[i] = mka<T>(m); return ret; }
        static T[][][] mka<T>(int n, int m, int l) where T : new() { T[][][] ret = new T[n][][]; for (int i = 0; i < n; i++) ret[i] = mka<T>(m, l); return ret; }
        static T[][][][] mka<T>(int n, int m, int l, int k) where T : new() { T[][][][] ret = new T[n][][][]; for (int i = 0; i < n; i++) ret[i] = mka<T>(m, l, k); return ret; }

    }

}

提出情報

提出日時
問題 C - Odd One Subsequence
ユーザ kuuso
言語 C# 11.0 (.NET 7.0.7)
得点 300
コード長 2955 Byte
結果 AC
実行時間 99 ms
メモリ 53908 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 2
AC × 28
セット名 テストケース
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 41 ms 25200 KiB
example_01.txt AC 49 ms 25236 KiB
hand_00.txt AC 92 ms 53908 KiB
hand_01.txt AC 70 ms 41860 KiB
hand_02.txt AC 76 ms 38976 KiB
hand_03.txt AC 38 ms 25312 KiB
hand_04.txt AC 48 ms 25264 KiB
hand_05.txt AC 67 ms 39976 KiB
random_00.txt AC 91 ms 48036 KiB
random_01.txt AC 93 ms 48028 KiB
random_02.txt AC 99 ms 48240 KiB
random_03.txt AC 97 ms 48072 KiB
random_04.txt AC 98 ms 48124 KiB
random_05.txt AC 75 ms 40912 KiB
random_06.txt AC 82 ms 40772 KiB
random_07.txt AC 75 ms 40788 KiB
random_08.txt AC 78 ms 40916 KiB
random_09.txt AC 82 ms 41076 KiB
random_10.txt AC 72 ms 38624 KiB
random_11.txt AC 72 ms 38884 KiB
random_12.txt AC 58 ms 38620 KiB
random_13.txt AC 71 ms 38520 KiB
random_14.txt AC 64 ms 38780 KiB
random_15.txt AC 76 ms 37792 KiB
random_16.txt AC 63 ms 37596 KiB
random_17.txt AC 73 ms 37360 KiB
random_18.txt AC 73 ms 37424 KiB
random_19.txt AC 76 ms 37636 KiB