結果

問題 No.989 N×Mマス計算(K以上)
ユーザー tamarontamaron
提出日時 2020-02-14 21:49:36
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 1,656 bytes
コンパイル時間 1,840 ms
コンパイル使用メモリ 169,984 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 01:47:32
合計ジャッジ時間 2,758 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define eachdo(e,array) for(const auto& e : array)
#define lower_index(v,a) (int)distance(v.begin(), lower_bound((v).begin(),(v).end(),a))
template<class T> bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 400005;
long long fac[MAX], finv[MAX], inv[MAX];


ll modpow(ll a, ll n, ll mod=MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll modinv(ll a,ll m=MOD) {
    ll b=m,u=1,v=0;
    while(b){
        ll t=a/b;
        a-=t*b;
        swap(a,b);
        u-=t*v;
        swap(u,v);
    }
    u%=m;
    if(u<0) u+=m;
    return u;
}

void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (ll i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i] =MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll COM(ll n, ll k){
    if (n<k)
        return 0;
    if (n<0 || k<0)
        return 0;
    return fac[n]*(finv[k]*finv[n - k]%MOD)%MOD;
}
int main(){ 
    ll H,W,K;cin >> H >> W >> K;
    string op;cin >> op;
    vector<ll> h(H),w(W);
    rep(i,W) cin >> w[i];
    rep(i,H) cin >> h[i];
    sort(h.begin(),h.end());
    sort(w.begin(),w.end());

    ll res = 0;
    if(op == "+"){
        rep(i,H){
            res += W-lower_index(w,K-h[i]);
        }
    }else{
        rep(i,H){
            res += W-lower_index(w,(K+h[i]-1)/h[i]);
        }
    }
    cout << res << endl;

}
0