結果

問題 No.966 引き算をして門松列(その1)
ユーザー pengin_2000pengin_2000
提出日時 2020-03-05 17:22:00
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 722 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 30,464 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-22 02:38:45
合計ジャッジ時間 806 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 0 ms
6,944 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 4 ms
6,940 KB
testcase_06 AC 6 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
int main()
{
	int t;
	scanf("%d", &t);
	int a, b, c;
	int x, y, z;
	int ans;
	int v;
	for (; t > 0; t--)
	{
		scanf("%d %d %d", &a, &b, &c);
		ans = -1;
		v = 0;
		x = a;
		y = b;
		z = c;
		if (x == z)
		{
			v++;
			z--;
		}
		if (x < z)
			z = x;
		if (z > 1)
		{
			if (z <= y)
				v += y - z + 1;
			ans = v;
		}
		x = a;
		y = b;
		z = c;
		v = 0;
		if (x >= y)
		{
			v += x - y + 1;
			x = y - 1;
		}
		if (x > 1)
		{
			if (x <= z)
				v += z - x + 1;
			if (ans<0 || ans>v)
				ans = v;
		}
		x = a;
		v = 0;
		if (z >= y)
		{
			v += z - y + 1;
			z = y - 1;
		}
		if (z > 1)
		{
			if (x >= z)
				v += x - z + 1;
			if (ans<0 || ans>v)
				ans = v;
		}
		printf("%d\n", ans);
	}
	return 0;
}
0