結果

問題 No.178 美しいWhitespace (1)
ユーザー ElkElk
提出日時 2018-06-06 00:00:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 760 bytes
コンパイル時間 237 ms
コンパイル使用メモリ 31,908 KB
実行使用メモリ 8,944 KB
最終ジャッジ日時 2023-09-12 22:39:15
合計ジャッジ時間 4,052 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

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

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

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

    return 0;
}
0