結果

問題 No.158 奇妙なお使い
ユーザー 古寺いろは古寺いろは
提出日時 2015-03-25 20:45:48
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,418 bytes
コンパイル時間 1,109 ms
コンパイル使用メモリ 144,540 KB
実行使用メモリ 814,892 KB
最終ジャッジ日時 2023-09-11 10:15:31
合計ジャッジ時間 5,621 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘bool useB()’:
main.cpp:20:9: warning: control reaches end of non-void function [-Wreturn-type]
  now[2] += B[2] - use2;
  ~~~~~~~^~~~~~~~~~~~~~
main.cpp: In function ‘bool useC()’:
main.cpp:34:9: warning: control reaches end of non-void function [-Wreturn-type]
  now[2] += C[2] - use2;
  ~~~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;


int A[3], B[3], C[3];
int now[3];
int DB, DC;

bool useB(){
	int nokori = DB;
	int use0 = min(now[0], nokori / 1000);
	nokori -= use0 * 1000;
	int use1 = min(now[1], nokori / 100);
	nokori -= use1 * 100;
	int use2 = min(now[2], nokori / 1);
	nokori -= use2 * 1;
	if (nokori != 0) return false;
	now[0] += B[0] - use0;
	now[1] += B[1] - use1;
	now[2] += B[2] - use2;
}

bool useC(){
	int nokori = DC;
	int use0 = min(now[0], nokori / 1000);
	nokori -= use0 * 1000;
	int use1 = min(now[1], nokori / 100);
	nokori -= use1 * 100;
	int use2 = min(now[2], nokori / 1);
	nokori -= use2 * 1;
	if (nokori != 0) return false;
	now[0] += C[0] - use0;
	now[1] += C[1] - use1;
	now[2] += C[2] - use2;
}

int main() {
	cin >> A[0] >> A[1] >> A[2];
	cin >> DB;
	cin >> B[0] >> B[1] >> B[2];
	cin >> DC;
	cin >> C[0] >> C[1] >> C[2];

	int ans = 0;
	for (int i = 0; i <= 10000; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			now[j] = A[j];
		}
		int nokori = i;
		int count = 0;
		while (1){
			if (nokori > 0 && useB()) count++;
			else if (useC()) count++;
			else break;
		}
		ans = max(ans, count);
	}

	for (int i = 0; i <= 10000; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			now[j] = A[j];
		}
		int nokori = i;
		int count = 0;
		while (1){
			if (nokori > 0 && useC()) count++;
			else if (useB()) count++;
			else break;
		}
		ans = max(ans, count);
	}
	cout << ans << endl;
}


0