結果

問題 No.2374 ASKT Subsequences
ユーザー 👑 kakel-sankakel-san
提出日時 2023-07-07 22:11:27
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 1,470 bytes
コンパイル時間 1,816 ms
コンパイル使用メモリ 65,856 KB
実行使用メモリ 57,712 KB
最終ジャッジ日時 2023-09-28 23:31:26
合計ジャッジ時間 6,004 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
23,740 KB
testcase_01 AC 62 ms
23,704 KB
testcase_02 AC 62 ms
23,680 KB
testcase_03 AC 62 ms
23,584 KB
testcase_04 AC 61 ms
21,508 KB
testcase_05 AC 62 ms
21,684 KB
testcase_06 AC 61 ms
19,516 KB
testcase_07 AC 62 ms
21,912 KB
testcase_08 AC 61 ms
21,688 KB
testcase_09 AC 62 ms
21,672 KB
testcase_10 AC 64 ms
22,664 KB
testcase_11 AC 79 ms
25,584 KB
testcase_12 AC 72 ms
21,836 KB
testcase_13 AC 71 ms
23,392 KB
testcase_14 AC 82 ms
27,496 KB
testcase_15 AC 85 ms
29,340 KB
testcase_16 AC 79 ms
28,284 KB
testcase_17 AC 91 ms
31,488 KB
testcase_18 AC 107 ms
34,988 KB
testcase_19 AC 106 ms
35,912 KB
testcase_20 AC 133 ms
47,008 KB
testcase_21 AC 144 ms
49,620 KB
testcase_22 AC 122 ms
42,632 KB
testcase_23 AC 109 ms
37,292 KB
testcase_24 AC 109 ms
37,360 KB
testcase_25 AC 104 ms
37,296 KB
testcase_26 AC 181 ms
57,712 KB
testcase_27 AC 142 ms
53,788 KB
testcase_28 AC 154 ms
55,712 KB
testcase_29 AC 140 ms
55,604 KB
testcase_30 AC 149 ms
55,692 KB
権限があれば一括ダウンロードができます

ソースコード

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 a = NList;
        WriteLine(Askt(n, a));
    }
    static long Askt(int n, int[] a)
    {
        var left = new int[n][];
        var right = new int[n][];
        for (var i = 0; i < n; ++i)
        {
            left[i] = new int[2001];
            right[i] = new int[2001];
        }
        left[0][a[0]] = 1;
        for (var i = 1; i < n; ++i) for (var j = 0; j < left[i].Length; ++j)
        {
            left[i][j] = left[i - 1][j];
            if (j == a[i]) ++left[i][j];
        }
        right[n - 1][a[n - 1]] = 1;
        for (var i = n - 2; i >= 0; --i) for (var j = 0; j < right[i].Length; ++j)
        {
            right[i][j] = right[i + 1][j];
            if (j == a[i]) ++right[i][j];
        }
        var ans = 0L;
        for (var i = 1; i < n; ++i) for (var j = i + 1; j + 1 < n; ++j)
        {
            if (a[i] <= a[j]) continue;
            var a1 = a[j] - 10;
            var a4 = a[i] + 1;
            if (a1 < 0 || a4 > 2000) continue;
            ans += left[i - 1][a1] * right[j + 1][a4];
        }
        return (ans);
    }
}
0