結果
| 問題 |
No.989 N×Mマス計算(K以上)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-19 20:25:29 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 101 ms / 2,000 ms |
| コード長 | 1,265 bytes |
| コンパイル時間 | 1,479 ms |
| コンパイル使用メモリ | 90,848 KB |
| 最終ジャッジ日時 | 2025-01-09 21:44:21 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
template <class T>
std::map<T, int> compress(std::vector<T>& v) {
std::sort(v.begin(), v.end());
v.erase(std::unique(v.begin(), v.end()), v.end());
std::map<T, int> rev;
for (int i = 0; i < (int)v.size(); ++i) rev[v[i]] = i;
return rev;
}
using lint = long long;
constexpr lint INF = 1LL << 60;
void solve() {
int n, m;
lint k;
char op;
std::cin >> n >> m >> k >> op;
std::vector<lint> xs(m);
for (auto& x : xs) std::cin >> x;
auto nxs = xs;
nxs.push_back(-INF);
auto revx = compress(nxs);
std::vector<lint> cnt(revx.size() + 1, 0);
for (auto x : xs) ++cnt[revx[x]];
for (int i = 1; i <= (int)revx.size(); ++i) cnt[i] += cnt[i - 1];
lint ans = 0;
while (n--) {
lint y;
std::cin >> y;
lint lx;
if (op == '+') {
lx = k - y;
} else {
lx = (k + y - 1) / y;
}
int i = std::lower_bound(nxs.begin(), nxs.end(), lx) -
nxs.begin();
ans += m - cnt[i - 1];
}
std::cout << ans << std::endl;
}
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
solve();
return 0;
}