結果

問題 No.989 N×Mマス計算(K以上)
ユーザー forest3forest3
提出日時 2020-07-17 09:54:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 691 bytes
コンパイル時間 1,696 ms
コンパイル使用メモリ 170,104 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 13:38:21
合計ジャッジ時間 3,673 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

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

int main()
{
	int N, M;
	long long K;
	char op;
	cin >> N >> M >> K >> op;
	vector<long long> B( M );
	vector<long long> A( N );
	for( int i = 0; i < M; i++ ) {
		cin >> B[i];
	}
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}

	sort( B.begin(), B.end() );
	long long ans = 0;
	if( op == '+' ) {
		for( int i = 0; i < N; i++ ) {
			long long k = K - A[i];
			int n = B.end() - lower_bound( B.begin(), B.end(), k );
			ans += n;
		}
	}
	else {
		for( int i = 0; i < N; i++ ) {
			int n = B.end() - lower_bound( B.begin(), B.end(), K,
				[&]( long long a, long long b ) { return a * A[i] < b; } );
			ans += n;
		}
	}

	cout << ans << endl;
}
0