結果

問題 No.149 碁石の移動
ユーザー TLwiegehttTLwiegehtt
提出日時 2015-07-07 21:22:18
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 467 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 20,096 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 03:08:28
合計ジャッジ時間 914 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:8:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%d %d", &white,&black);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:11:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%d %d", &white,&black);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:15:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |         scanf("%d %d", &c,&d);
      |         ^~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main(void){
	int a[2], b[2];
	int c,d;
	int white, black;
	
	scanf("%d %d", &white,&black);
	a[0] = white;
	a[1] = black;
	scanf("%d %d", &white,&black);
	b[0] = white;
	b[1] = black;
	
	scanf("%d %d", &c,&d);
	
	if( c >= a[1] ){
		b[1] += a[1];
		c = c - a[1];
		a[1] = 0;
	}else{
		b[1] += c;
		a[1] -= c;
		c = 0;
	}
	
	b[0] += c;
	a[0] -= c;
	
	if( d >= b[0] ){
		a[0] += b[0];
	}else{
		a[0] += d;
	}
	
	printf("%d\n", a[0]);
	return 0;
}
0