結果

問題 No.989 N×Mマス計算(K以上)
ユーザー ysystem7ysystem7
提出日時 2020-07-27 21:23:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 2,331 bytes
コンパイル時間 2,196 ms
コンパイル使用メモリ 203,788 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-11 06:02:17
合計ジャッジ時間 3,774 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,m,k;
    cin>>n>>m>>k;
    char c;
    cin>>c;
    V<ll>b(m),a(n);
    cinf(m,b);
    cinf(n,a);
    sort(all(b));
    ll ans=0;
    if(c=='+'){
        rep(i,n){
        ll x=lb(all(b),k-a[i])-b.begin();
        ans+=m-x;
        }
    }else{
        rep(i,n){
        ll y=k/a[i];
        if(k%a[i]!=0)y++;
        ll x=lb(all(b),y)-b.begin();
        ans+=m-x;
        }
    }
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない ACできると信じろ!!!
//どうしてもわからないときはサンプルで実験 何か見えてくるかも
//頭で考えてダメなら紙におこせ!!
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ!
(適切にmodをとれ にぶたんで途中で切り上げろ)
制約をよく読め!
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意!(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ!
doubleを扱うときには(abs)ではなく'fabs'!!!
*/
0