結果

問題 No.178 美しいWhitespace (1)
ユーザー くれちーくれちー
提出日時 2016-08-24 17:56:52
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 495 bytes
コンパイル時間 745 ms
コンパイル使用メモリ 21,248 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 15:06:27
合計ジャッジ時間 826 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 0 ms
6,940 KB
testcase_02 AC 0 ms
6,944 KB
testcase_03 AC 0 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 0 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 0 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 0 ms
6,940 KB
testcase_16 AC 0 ms
6,944 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 1 ms
6,944 KB
testcase_19 AC 1 ms
6,940 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 AC 1 ms
6,940 KB
testcase_24 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%d", &n);
      |         ^~~~~~~~~~~~~~~
main.c:8:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%d %d", &a[0], &b[0]);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:11:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |                 scanf("%d %d", &a[i], &b[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main() {
	int n, a[1000], b[1000], i;
	long long int max, sum = 0;

	scanf("%d", &n);
	scanf("%d %d", &a[0], &b[0]);
	max = a[0] + b[0] * 4;
	for (i = 1; i < n; i++) {
		scanf("%d %d", &a[i], &b[i]);
		if ((a[i] + b[i] * 4) % 2 != 
			(a[i - 1] + b[i - 1] * 4) % 2) {
			printf("-1\n");
			return 0;
		}
		if (max < a[i] + b[i] * 4)
			max = a[i] + b[i] * 4;
	}

	for (i = 0; i < n; i++) {
		sum += (max - (a[i] + b[i] * 4)) / 2;
	}

	printf("%lld\n", sum);

	return 0;
}
0