結果

問題 No.2374 ASKT Subsequences
ユーザー Ekiben542Ekiben542
提出日時 2023-07-08 08:10:52
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,176 bytes
コンパイル時間 1,717 ms
コンパイル使用メモリ 95,932 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 09:28:44
合計ジャッジ時間 7,747 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 4 ms
4,380 KB
testcase_18 AC 8 ms
4,376 KB
testcase_19 AC 7 ms
4,376 KB
testcase_20 AC 11 ms
4,380 KB
testcase_21 AC 14 ms
4,380 KB
testcase_22 AC 10 ms
4,376 KB
testcase_23 AC 8 ms
4,380 KB
testcase_24 AC 8 ms
4,376 KB
testcase_25 WA -
testcase_26 AC 28 ms
4,376 KB
testcase_27 TLE -
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