結果

問題 No.989 N×Mマス計算(K以上)
ユーザー CELICA
提出日時 2020-08-11 05:15:18
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 865 bytes
コンパイル時間 2,018 ms
コンパイル使用メモリ 172,964 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-09 11:09:07
合計ジャッジ時間 2,798 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using ll = long long;

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n, m, k;
    string op;
    cin >> n >> m >> k >> op;

    vector<ll> va(n), vb(m);

    for (int i = 0; i < m; ++i)
        cin >> vb[i];
    for (int i = 0; i < n; ++i)
        cin >> va[i];

    sort(va.begin(), va.end());

    ll res{ 0 };
    if (op == "+")
    {
        for (int i = 0; i < m; ++i)
        {
            vector<ll>::iterator it = lower_bound(va.begin(), va.end(), k - vb[i]);
            res += distance(it, va.end());
        }
    }
    else
    {
        for (int i = 0; i < m; ++i)
        {
            vector<ll>::iterator it = lower_bound(va.begin(), va.end(), (k + vb[i] - 1) / vb[i]);
            res += distance(it, va.end());
        }
    }

    cout << res << "\n";

    return 0;
}
0