結果

問題 No.989 N×Mマス計算(K以上)
コンテスト
ユーザー MarcusAureliusAntoninus
提出日時 2020-02-14 21:42:16
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 583 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,362 ms
コンパイル使用メモリ 216,248 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-08 18:55:23
合計ジャッジ時間 2,454 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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