結果

問題 No.2138 Add Bacon
ユーザー sean51cyansean51cyan
提出日時 2022-12-01 01:55:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,019 bytes
コンパイル時間 2,125 ms
コンパイル使用メモリ 205,360 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-07-29 13:50:43
合計ジャッジ時間 3,393 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,384 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using namespace std;
#include <bits/stdc++.h>
const int MOD = 998244353;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<vb> vvb;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef pair<ll, ll> pll;
typedef set<ll> sll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, N, n) for (int i = N; i < (n); i++)
#define SZ(x) (int)(x).size() // size_t
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
using Graph = vector<vector<int>>;

const ll INF = 1LL << 60;
vll dx = {-1, 0, 1, 0};
vll dy = {0, -1, 0, 1};

bool IsPrime(int num)
{
	if (num < 2)
		return false;
	else if (num == 2)
		return true;
	else if (num % 2 == 0)
		return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

// N の約数をすべて求める関数
vector<long long> calc_divisors(long long N)
{
	// 答えを表す集合
	vector<long long> res;

	// 各整数 i が N の約数かどうかを調べる
	for (long long i = 1; i * i <= N; ++i)
	{
		// i が N の約数でない場合はスキップ
		if (N % i != 0)
			continue;

		// i は約数である
		res.push_back(i);

		// N ÷ i も約数である (重複に注意)
		if (N / i != i)
			res.push_back(N / i);
	}

	// 約数を小さい順に並び替えて出力
	sort(res.begin(), res.end());
	return res;
}

void print(const vector<long long> &v)
{
	for (int i = 0; i < v.size(); ++i)
	{
		if (i)
			cout << v[i] << endl;
	}
}

int main()
{
	ll a, b, c, d, e, maxkouhuku,kohu;
	cin >> a >> b >> c >> d >> e;

	maxkouhuku = a - b;
	REP(i, c)
	{
		a += d;
		b += e;
		kohu = a - b;
		if (maxkouhuku < kohu)
		{
			maxkouhuku = kohu;
		}
	}

	cout << maxkouhuku << endl;

	return 0;
}
0