結果
| 問題 |
No.989 N×Mマス計算(K以上)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-02-14 21:37:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 60 ms / 2,000 ms |
| コード長 | 853 bytes |
| コンパイル時間 | 1,893 ms |
| コンパイル使用メモリ | 173,044 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-06 10:53:43 |
| 合計ジャッジ時間 | 2,886 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
int main() {
int n, m, k;
cin >> n >> m >> k;
char op;
cin >> op;
vector<long long> b(m);
vector<long long> a(n);
rep(i, m) cin >> b[i];
rep(i, n) cin >> a[i];
sort(a.begin(), a.end());
sort(b.begin(), b.end());
if(op == '+') {
long long total = 0;
rep(i, n) {
int c = k - a[i];
auto it = lower_bound(b.begin(), b.end(), c);
int dist = distance(b.begin(), it);
total += m - dist;
}
cout << total << endl;
}
else {
long long total = 0;
rep(i, n) {
int c;
if(k % a[i] == 0) c = k / a[i];
else c = (k / a[i] + 1);
auto it = lower_bound(b.begin(), b.end(), c);
int dist = distance(b.begin(), it);
total += m - dist;
}
cout << total << endl;
}
}