結果

問題 No.3173 じゃんけんの勝ちの回数
ユーザー pengin_2000
提出日時 2025-06-06 22:17:50
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 546 bytes
コンパイル時間 632 ms
コンパイル使用メモリ 25,728 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-06-06 22:17:53
合計ジャッジ時間 2,180 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 33
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘solve’:
main.c:8:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |                 scanf("%d", &a[i]);
      |                 ^~~~~~~~~~~~~~~~~~
main.c:10:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |                 scanf("%d", &b[i]);
      |                 ^~~~~~~~~~~~~~~~~~
main.c: In function ‘main’:
main.c:33:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   33 |         scanf("%d", &t);
      |         ^~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
void solve()
{
	int n = 3;
	int i;
	int a[3], b[3];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (i = 0; i < n; i++)
		scanf("%d", &b[i]);
	int ans;
	ans = 0;
	for (i = 0; i < n; i++)
	{
		if (a[i] > b[i] + b[(i + 2) % 3])
			ans += a[i] - b[i] - b[(i + 2) % 3];
	}
	printf("%d ", ans);
	ans = 0;
	for (i = 0; i < n; i++)
	{
		if (a[i] > b[(i + 1) % 3])
			ans += b[(i + 1) % 3];
		else
			ans += a[i];
	}
	printf("%d\n", ans);
	return;
}
int main()
{
	int t;
	scanf("%d", &t);
	for (; t > 0; t--)
		solve();
	return 0;
}
0