結果

問題 No.3065 Speedrun (Normal)
ユーザー pengin_2000
提出日時 2025-03-21 21:27:03
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 604 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 25,856 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2025-03-21 21:27:05
合計ジャッジ時間 992 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:6:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |                 scanf("%lld", &a[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~
main.c:8:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |                 scanf("%lld", &p[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~
main.c:9:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%lld", &t);
      |         ^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
int main()
{
	long long int a[4], p[4], t, i;
	for (i = 0; i < 4; i++)
		scanf("%lld", &a[i]);
	for (i = 0; i < 4; i++)
		scanf("%lld", &p[i]);
	scanf("%lld", &t);
	for (i = 0; i < 3; i++)
	{
		if (p[i] > p[i + 1])
		{
			p[i] ^= p[i + 1];
			p[i + 1] ^= p[i];
			p[i] ^= p[i + 1];
			a[i] ^= a[i + 1];
			a[i + 1] ^= a[i];
			a[i] ^= a[i + 1];
			if (i > 0)
				i -= 2;
		}
	}
	long long int ans = 0;
	for (i = 0; i < 4; i++)
	{
		if (a[i] * p[i] > t)
		{
			ans += t / p[i];
			t %= p[i];
		}
		else
		{
			t -= a[i] * p[i];
			ans += a[i];
		}
	}
	printf("%lld\n", ans);
	return 0;
}
0