結果

問題 No.3241 Make Multiplication of 8
ユーザー pengin_2000
提出日時 2025-08-22 21:24:46
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 555 bytes
コンパイル時間 133 ms
コンパイル使用メモリ 26,956 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-22 21:24:48
合計ジャッジ時間 1,577 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:6:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         scanf("%lld", &n);
      |         ^~~~~~~~~~~~~~~~~
main.c:9:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |                 scanf("%lld %lld", &a[i], &b[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

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