結果

問題 No.2374 ASKT Subsequences
ユーザー 2000 Ekiben2000 Ekiben
提出日時 2023-07-08 08:12:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,176 bytes
コンパイル時間 902 ms
コンパイル使用メモリ 86,128 KB
実行使用メモリ 13,884 KB
最終ジャッジ日時 2024-07-22 04:06:05
合計ジャッジ時間 4,896 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,884 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 3 ms
6,940 KB
testcase_15 AC 3 ms
6,940 KB
testcase_16 AC 2 ms
6,948 KB
testcase_17 AC 4 ms
6,944 KB
testcase_18 AC 9 ms
6,940 KB
testcase_19 AC 8 ms
6,944 KB
testcase_20 AC 15 ms
6,940 KB
testcase_21 AC 18 ms
6,944 KB
testcase_22 AC 12 ms
6,940 KB
testcase_23 AC 10 ms
6,940 KB
testcase_24 AC 10 ms
6,944 KB
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <unordered_map>
#include <vector>

int count_asakatsu_subsequences(int N, std::vector<int>& A) {
    int cnt = 0;
    std::unordered_map<int, std::vector<int>> indices;

    for (int i = 0; i < N; i++) {
        int a = A[i];
        indices[a].push_back(i);
    }

    for (int i = 0; i < N - 3; i++) {
        for (int j = i + 1; j < N - 2; j++) {
            int k = A[j] - A[i] - 10;
            if (k > 0) {
                std::vector<int>& m_values = indices[A[j] - k];
                for (int m : m_values) {
                    if (m > j) {
                        std::vector<int>& n_values = indices[A[m] + k + 1];
                        for (int n : n_values) {
                            if (n > m) {
                                cnt++;
                            }
                        }
                    }
                }
            }
        }
    }

    return cnt;
}

int main() {
    int N;
    std::cin >> N;
    std::vector<int> A(N);
    for (int i = 0; i < N; i++) {
        std::cin >> A[i];
    }

    int result = count_asakatsu_subsequences(N, A);

    std::cout << result << std::endl;

    return 0;
}
0