結果
問題 |
No.989 N×Mマス計算(K以上)
|
ユーザー |
|
提出日時 | 2020-07-05 19:40:05 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 70 ms / 2,000 ms |
コード長 | 1,205 bytes |
コンパイル時間 | 826 ms |
コンパイル使用メモリ | 78,520 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 18:58:24 |
合計ジャッジ時間 | 1,968 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; #define MOD 1000000007 int main() { int n, m, k; cin >> n >> m >> k; char op; cin >> op; vector<ll> b(m + 2); b[0] = -1e18; for (int i = 1; i <= m; ++i) { cin >> b[i]; } b[m + 1] = 1e18; vector<ll> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } sort(b.begin(), b.end()); ll ans = 0; if (op == '+') { for (int i = 0; i < n; ++i) { int ok = m + 1, ng = 0; while (1 < abs(ok - ng)) { int mid = (ok + ng) / 2; if (k - a[i] <= b[mid]) { ok = mid; } else { ng = mid; } } ans += m - ok + 1; } } else { for (int i = 0; i < n; ++i) { int ok = m + 1, ng = 0; while (1 < abs(ok - ng)) { int mid = (ok + ng) / 2; if ((k + a[i] - 1) / a[i] <= b[mid]) { ok = mid; } else { ng = mid; } } ans += m - ok + 1; } } cout << ans << endl; return 0; }