結果

問題 No.178 美しいWhitespace (1)
ユーザー TLwiegehtt
提出日時 2015-07-08 01:15:39
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 525 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 20,992 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-08 01:36:56
合計ジャッジ時間 733 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:9:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%d", &n);
      |         ^~~~~~~~~~~~~~~
main.c:12:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |                 scanf("%d %d", &a[i], &b[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main(void){
	int i,n;
	int evenodd = 0;
	int maxSpace = 0;
	int a[1010], b[1010];
	long long int ans = 0;
	scanf("%d", &n);
	for(i=0;i<n;i++){
		int calc;
		scanf("%d %d", &a[i], &b[i]);
		if(a[i]%2 == 0){
			evenodd |= 1;
		}else{
			evenodd |= 2;
		}
		
		calc = a[i] + 4 * b[i];
		if(maxSpace < calc ){
			maxSpace = calc;
		}
	}
	
	if(evenodd == 3){
		ans = -1;
	}else{
		for(i=0;i<n;i++){
			int calc = a[i] + 4 * b[i];
			ans += (maxSpace - calc)/2;
		}
	}
	
	printf("%lld\n", ans);
	return 0;
}
0