結果

問題 No.989 N×Mマス計算(K以上)
ユーザー Y17Y17
提出日時 2020-02-14 21:33:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 841 bytes
コンパイル時間 1,270 ms
コンパイル使用メモリ 160,608 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 01:34:56
合計ジャッジ時間 2,280 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 37 ms
5,376 KB
testcase_11 AC 37 ms
5,376 KB
testcase_12 AC 44 ms
5,376 KB
testcase_13 AC 24 ms
5,376 KB
testcase_14 AC 58 ms
5,376 KB
testcase_15 AC 18 ms
5,376 KB
testcase_16 AC 29 ms
5,376 KB
testcase_17 AC 24 ms
5,376 KB
testcase_18 AC 21 ms
5,376 KB
testcase_19 AC 36 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main(){

    int n, m;
    cin >> n >> m;
    int k;
    cin >> k;

    char op;
    cin >> op;

    int a[100010];
    int b[100010];
    int sum = 0;

    for(int i = 0;i < m;i++){
        cin >> b[i];
    }

    sort(b, b+m);

    for(int i = 0;i < n;i++) cin >> a[i];

    int ans = 0;
    for(int i = 0;i < n;i++){
        if(op == '+'){
            ans += m-(lower_bound(b, b+m, k-a[i])-b); 
        }else{
            int l = 0, r = k;
            while(r-l > 1){
                int mid = (l+r)/2;
                if(mid*a[i] >= k){
                    r = mid;
                }else{
                    l = mid;
                }
            }

            ans += m-(lower_bound(b, b+m, r)-b);
        }
    }
	
    cout << ans << endl;

    return 0;
}
0