結果

問題 No.989 N×Mマス計算(K以上)
ユーザー Strorkis
提出日時 2020-02-14 21:51:15
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 584 bytes
コンパイル時間 798 ms
コンパイル使用メモリ 75,588 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-06 11:22:25
合計ジャッジ時間 1,913 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
  int n, m, k; cin >> n >> m >> k;
  char op; cin >> op;
  vector<int> b(m);
  for (int i = 0; i < m; i++) cin >> b[i];
  sort(b.begin(), b.end(), greater<int>());

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    int x = op == '+' ? max(0, k-a) : (k + a - 1) / a;
    int l = 0, r = m;
    while(l < r) {
      int c = (l + r) / 2;
      if (x > b[c])
        r = c;
      else
        l = c + 1;
    }
    ans += l;
  }
  cout << ans << endl;
}
0