結果

問題 No.989 N×Mマス計算(K以上)
ユーザー SSRSSSRS
提出日時 2020-11-12 00:07:51
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 744 bytes
コンパイル時間 1,462 ms
コンパイル使用メモリ 170,552 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 00:58:23
合計ジャッジ時間 3,566 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 39 ms
4,380 KB
testcase_11 AC 34 ms
4,376 KB
testcase_12 AC 44 ms
4,380 KB
testcase_13 AC 21 ms
4,376 KB
testcase_14 AC 60 ms
4,380 KB
testcase_15 AC 17 ms
4,376 KB
testcase_16 AC 32 ms
4,376 KB
testcase_17 AC 21 ms
4,380 KB
testcase_18 AC 24 ms
4,380 KB
testcase_19 AC 35 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:31:7: 警告: ‘num’ may be used uninitialized [-Wmaybe-uninitialized]
   31 |       if (num >= K){
      |       ^~
main.cpp:24:17: 備考: ‘num’ はここで定義されています
   24 |       long long num;
      |                 ^~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M, K;
  cin >> N >> M >> K;
  char op;
  cin >> op;
  vector<long long> B(M);
  for (int i = 0; i < M; i++){
    cin >> B[i];
  }
  vector<long long> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  long long ans = 0;
  for (int i = 0; i < N; i++){
    int tv = M;
    int fv = -1;
    while (tv - fv > 1){
      int mid = (tv + fv) / 2;
      long long num;
      if (op == '+'){
        num = A[i] + B[mid];
      }
      if (op == '*'){
        num = A[i] * B[mid];
      }
      if (num >= K){
        tv = mid;
      } else {
        fv = mid;
      }
    }
    ans += M - tv;
  }
  cout << ans << endl;
}
0