結果

問題 No.135 とりあえず1次元の問題
ユーザー ElkElk
提出日時 2018-05-28 14:44:25
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 712 bytes
コンパイル時間 1,087 ms
コンパイル使用メモリ 25,648 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-12 20:05:53
合計ジャッジ時間 1,991 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
evil01.txt AC 12 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main(){
    int N, i, max = 0, max_i = 0, sub, cnt = 0;
    int num[100000];

    scanf("%d\n", &N);
    for(i = 0; i < N; i++){
        scanf("%d", &num[i]);
        if(i > 0 && num[i] == num[i - 1]){
            cnt++;
            if(cnt == N - 1){
                printf("0\n");
                return 0;
            }
        }
    }
    max = num[0];
    for(i = 0; i < N; i++){
        if(max <= num[i]){
            max = num[i];
            max_i = i;
        }
    }
    sub = max - num[0];
    for(i = 0; i < N; i++){
        if((max - num[i]) < sub && i != max_i && (max - num[i] != 0)){
            sub = max - num[i];
        }
    }
    printf("%d\n", sub);
    return 0;
}
0