結果

問題 No.989 N×Mマス計算(K以上)
ユーザー MarcusAureliusAntoninusMarcusAureliusAntoninus
提出日時 2020-02-14 21:42:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 583 bytes
コンパイル時間 2,596 ms
コンパイル使用メモリ 200,316 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 01:40:39
合計ジャッジ時間 3,603 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 22 ms
5,376 KB
testcase_11 AC 20 ms
5,376 KB
testcase_12 AC 25 ms
5,376 KB
testcase_13 AC 14 ms
5,376 KB
testcase_14 AC 38 ms
5,376 KB
testcase_15 AC 11 ms
5,376 KB
testcase_16 AC 18 ms
5,376 KB
testcase_17 AC 14 ms
5,376 KB
testcase_18 AC 14 ms
5,376 KB
testcase_19 AC 22 ms
5,376 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