結果

問題 No.178 美しいWhitespace (1)
ユーザー ElkElk
提出日時 2018-06-06 00:17:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 850 bytes
コンパイル時間 321 ms
コンパイル使用メモリ 32,316 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-12 22:39:34
合計ジャッジ時間 1,390 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int func(const void *a, const void *b){
    return *(int *)a - *(int *)b;
}

int main(){
    long long int N, i;
    long long int a[1000], b[1000], width[1000];
    long long int cnt = 0, sub, divi;

    scanf("%lld\n", &N);
    for(i = 0; i < N; i++){
        scanf("%lld %lld\n", &a[i], &b[i]);
        width[i] = a[i] + 4*b[i];
    }
    qsort(width, N, sizeof(long long int), func);
    /*
    for(i = 0; i < N; i++){
        printf("%lld\n", width[i]);
    }
    */
    for(i = 0; i < N; i++){
        sub =  width[N - 1] - width[i];
        //printf("max %lld\n", width[N - 1]);
        if(sub > 0){
            divi = sub/2;
            if(sub%2 == 0){
                cnt += divi;
            }else{
                return -1;
            }
        }
    }
    printf("%lld\n", cnt);

    return 0;
}
0