結果

問題 No.989 N×Mマス計算(K以上)
ユーザー kiefer_von_mauskiefer_von_maus
提出日時 2020-06-08 01:22:27
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 826 bytes
コンパイル時間 1,558 ms
コンパイル使用メモリ 170,872 KB
実行使用メモリ 4,416 KB
最終ジャッジ日時 2023-08-25 14:37:51
合計ジャッジ時間 2,708 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long double pi = acos(-1.0); 
typedef long long ll;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, m, k;
	cin >> n >> m >> k;
	char op;
	cin >> op;
	vector<ll> b(m);
	vector<ll> a(n);
	for(int i = 0; i < m; i++) {
		cin >>  b[i];
	}
	sort(b.begin(), b.end());
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		ll right, left, mid;
		right = m;
		left = -1;
		while(right - left > 1) {
			mid = (right + left) / 2;
			if(op == '+') {
				if(a[i] + b[mid] < k) {
					left = mid;
				}else {
					right = mid;
				}
			}else if(op == '*') {
				if((ll)a[i] * b[mid] < k) {
					left = mid;
				}else {
					right = mid;
				}
			}
		} 
		ans += m - right;
	}
	cout << ans << endl;
}
0