結果

問題 No.178 美しいWhitespace (1)
コンテスト
ユーザー くれちー
提出日時 2016-08-24 17:56:52
言語 C90
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 495 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 142 ms
コンパイル使用メモリ 30,280 KB
最終ジャッジ日時 2026-02-23 22:17:01
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 #
raw source code

#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