結果

問題 No.2374 ASKT Subsequences
ユーザー Himatsubushin
提出日時 2023-07-11 15:31:08
言語 C90
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 778 bytes
コンパイル時間 576 ms
コンパイル使用メモリ 22,400 KB
実行使用メモリ 14,024 KB
最終ジャッジ日時 2024-09-13 05:46:22
合計ジャッジ時間 8,083 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 TLE * 2 -- * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:12:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |     scanf("%d", &n);
      |     ^~~~~~~~~~~~~~~
main.c:14:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |         scanf("%d", &x[i]);
      |         ^~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

#define N 2000

bool check(int, int, int, int);

int main(void) {
    int a, b, c, d, i, n, count, x[N];

    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", &x[i]);

    count = 0;
    for (a = 0; a < n - 3; a++)
        for (b = a + 1; b < n - 2; b++)
            for (c = b + 1; c < n - 1; c++)
                for (d = c + 1; d < n; d++)
                    if (check(x[a], x[b], x[c], x[d]))
                        count++;

    printf("%d\n", count);

    return EXIT_SUCCESS;
}

bool check(int a, int b, int c, int d) {
    int k1, k2, k3;

    k1 = b - a - 10;
    k2 = b - c;
    k3 = d - c - 1;

    if (k1 > 0 && k1 == k2 && k2 == k3)
        return true;
    else
        return false;
}
0