結果

問題 No.1586 Equal Array
ユーザー masakunmmasakunm
提出日時 2021-07-08 22:25:22
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,985 bytes
コンパイル時間 4,726 ms
コンパイル使用メモリ 110,004 KB
実行使用メモリ 35,072 KB
最終ジャッジ日時 2023-09-14 05:05:13
合計ジャッジ時間 7,682 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
20,756 KB
testcase_01 AC 49 ms
20,740 KB
testcase_02 AC 51 ms
20,732 KB
testcase_03 AC 52 ms
22,752 KB
testcase_04 AC 83 ms
27,764 KB
testcase_05 AC 81 ms
25,768 KB
testcase_06 AC 97 ms
30,512 KB
testcase_07 AC 92 ms
28,488 KB
testcase_08 AC 94 ms
30,536 KB
testcase_09 AC 94 ms
28,504 KB
testcase_10 AC 96 ms
28,496 KB
testcase_11 AC 51 ms
22,824 KB
testcase_12 AC 51 ms
20,736 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 54 ms
22,828 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 50 ms
20,708 KB
testcase_21 AC 51 ms
20,708 KB
testcase_22 AC 52 ms
22,816 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.Linq;
using System.Collections.Generic;
using System.Text;

namespace Main {
    class Program {

        static void Main(string[] args) {
            int N = ReadInt1();
            int[] Ary = ReadIntAry();

            int sum = 0; 
            for (int i = 0; i < N; i++) {
                sum += Ary[i];
            }

            Console.WriteLine((sum % N == 0) ? "Yes" : "No");
        }

        public static int Lcm(int a, int b) {
            return a * b / Gcd(a, b);
        }
        public static int Gcd(int a, int b) {
            if (a < b)
                return Gcd(b, a);
            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
        static void AddValue2Dic(ref Dictionary<string, int> dic, string key, int val) {
            if (!dic.ContainsKey(key))
                dic.Add(key, val);
            else
                dic[key] += val;
        }
        static void AddValue2Dic(ref Dictionary<int, int> dic, int key, int val) {
            if (!dic.ContainsKey(key))
                dic.Add(key, val);
            else
                dic[key] += val;
        }

        static long[] ReadLongAry() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        static long ReadLong1() { return long.Parse(Console.ReadLine()); }
        static (long, long) ReadLong2() { var x = ReadLongAry(); return (x[0], x[1]); }
        static (long, long, long) ReadLong3() { var x = ReadLongAry(); return (x[0], x[1], x[2]); }

        static int[] ReadIntAry() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        static int ReadInt1() { return int.Parse(Console.ReadLine()); }
        static (int, int) ReadInt2() { var x = ReadIntAry(); return (x[0], x[1]); }
        static (int, int, int) ReadInt3() { var x = ReadIntAry(); return (x[0], x[1], x[2]); }

        static string[] ReadStrAry() => Console.ReadLine().Split();
        static string ReadStr1() { return Console.ReadLine(); }
        static (string, string) ReadStr2() { var x = ReadStrAry(); return (x[0], x[1]); }
        static (string, string, string) ReadStr3() { var x = ReadStrAry(); return (x[0], x[1], x[2]); }
    }

    public static class Combination {
        public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) {
            if (k == 1) {
                foreach (var item in items)
                    yield return new T[] { item };
                yield break;
            }
            foreach (var item in items) {
                var leftside = new T[] { item };
                var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();
                foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) {
                    yield return leftside.Concat(rightside).ToArray();
                }
            }
        }
    }
}
0