結果

問題 No.1095 Smallest Kadomatsu Subsequence
ユーザー yk1095yk1095
提出日時 2020-07-03 11:24:03
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,501 bytes
コンパイル時間 2,408 ms
コンパイル使用メモリ 64,184 KB
実行使用メモリ 28,004 KB
最終ジャッジ日時 2023-10-14 22:44:05
合計ジャッジ時間 6,552 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
28,004 KB
testcase_01 AC 59 ms
23,628 KB
testcase_02 AC 60 ms
21,496 KB
testcase_03 AC 61 ms
21,576 KB
testcase_04 AC 60 ms
23,524 KB
testcase_05 AC 59 ms
19,516 KB
testcase_06 AC 59 ms
23,548 KB
testcase_07 AC 60 ms
21,600 KB
testcase_08 AC 62 ms
21,640 KB
testcase_09 AC 61 ms
21,532 KB
testcase_10 AC 59 ms
23,576 KB
testcase_11 AC 61 ms
23,612 KB
testcase_12 AC 58 ms
23,588 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var A = ReadLongs();

            var min = long.MaxValue;
            for (var i = 0; i < N - 2; i++)
            {
                for (var j = i + 1; j < N - 1; j++)
                {
                    for (var k = j + 1; k < N; k++)
                    {
                        var a = A[i];
                        var b = A[j];
                        var c = A[k];

                        if (a == b || b == c || c == a) continue;
                        if (b < a && b < c || b > a && b > c)
                        {
                            min = Math.Min(min, a + b + c);
                        }
                    }
                }
            }

            return min == long.MaxValue ? -1 : min;
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}
0