結果

問題 No.3241 Make Multiplication of 8
ユーザー 👑 ygussany
提出日時 2025-08-16 10:37:07
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 27,340 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-16 10:37:11
合計ジャッジ時間 2,987 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("%d", &N);
      |         ^~~~~~~~~~~~~~~
main.c:7:34: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         for (i = 1; i <= N; i++) scanf("%d %d", &(A[i]), &(B[i]));
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main()
{
	int i, N, A[100000], B[100000];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d %d", &(A[i]), &(B[i]));
	
	int j, k;
	long long num[4] = {};
	for (i = 1; i <= N; i++) {
		for (j = 0; j < 3; j++) {
			if (A[i] % 2 != 0) break;
			A[i] /= 2;
		}
		num[j] += B[i];
	}
	
	long long ans = num[3];
	if (num[1] > num[2]) {
		ans += num[2];
		num[1] -= num[2];
		ans += num[1] / 3;
	} else {
		ans += num[1];
		num[2] -= num[1];
		ans += num[2] / 2;
	}
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}
0