結果

問題 No.989 N×Mマス計算(K以上)
ユーザー sosamjayososamjayo
提出日時 2020-03-27 04:34:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 1,824 bytes
コンパイル時間 1,047 ms
コンパイル使用メモリ 86,544 KB
実行使用メモリ 4,440 KB
最終ジャッジ日時 2023-08-30 16:02:40
合計ジャッジ時間 2,826 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 34 ms
4,380 KB
testcase_11 AC 34 ms
4,376 KB
testcase_12 AC 39 ms
4,376 KB
testcase_13 AC 22 ms
4,376 KB
testcase_14 AC 54 ms
4,440 KB
testcase_15 AC 15 ms
4,376 KB
testcase_16 AC 27 ms
4,376 KB
testcase_17 AC 22 ms
4,376 KB
testcase_18 AC 20 ms
4,376 KB
testcase_19 AC 34 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//




int main() {

    int n, m, k;
    cin >> n >> m >> k;
    char op; cin >> op;
    vector<ll> a(n), b(m);
    rep(i,m) cin >> b[i];
    rep(i,n) cin >> a[i];
    Sort(b);

    ll ans = 0;
    if (op == '+') {
        rep(i,n) ans += b.end() - lower_bound(b.begin(), b.end(), k - a[i]);
    }
    else {
        rep(i,n) {
            if (k % a[i] == 0) ans += b.end() - lower_bound(b.begin(), b.end(), k / a[i]);
            else ans += b.end() - upper_bound(b.begin(), b.end(), k / a[i]);
        }
    }
    out(ans);

    return 0;
}








0