結果

問題 No.989 N×Mマス計算(K以上)
ユーザー MarcusAureliusAntoninusMarcusAureliusAntoninus
提出日時 2020-02-14 21:42:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 583 bytes
コンパイル時間 2,552 ms
コンパイル使用メモリ 203,376 KB
実行使用メモリ 5,228 KB
最終ジャッジ日時 2023-07-28 17:35:04
合計ジャッジ時間 3,340 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 21 ms
4,376 KB
testcase_11 AC 20 ms
4,384 KB
testcase_12 AC 24 ms
4,752 KB
testcase_13 AC 13 ms
4,376 KB
testcase_14 AC 33 ms
5,228 KB
testcase_15 AC 9 ms
4,380 KB
testcase_16 AC 18 ms
4,380 KB
testcase_17 AC 13 ms
4,376 KB
testcase_18 AC 13 ms
4,376 KB
testcase_19 AC 20 ms
4,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int main()
{
	int N, M;
	int64_t K;
	char op;
	scanf("%d%d%lld %c", &N, &M, &K, &op);
	std::vector<int64_t> A(N), B(M);
	for (auto& e: B)
		scanf("%lld", &e);
	for (auto& e: A)
		scanf("%lld", &e);
	std::sort(A.begin(), A.end());
	std::sort(B.begin(), B.end());
	B.push_back(1'000'000'000);

	auto calc{
		[&](int64_t a, int64_t b)
		{
			if (op == '+') return a + b;
			else return a * b;
		}
	};
	int64_t ans{};
	int ok{M};
	for (auto& e: A)
	{
		while (ok > 0 && calc(e, B[ok - 1]) >= K)
			ok--;
		ans += M - ok;
	}
	printf("%lld\n", ans);

	return 0;
}
0