結果

問題 No.989 N×Mマス計算(K以上)
ユーザー edamame882edamame882
提出日時 2020-02-14 22:03:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 2,673 bytes
コンパイル時間 1,725 ms
コンパイル使用メモリ 172,508 KB
実行使用メモリ 5,372 KB
最終ジャッジ日時 2023-07-28 18:02:06
合計ジャッジ時間 3,027 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 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 21 ms
4,700 KB
testcase_11 AC 20 ms
4,376 KB
testcase_12 AC 23 ms
4,640 KB
testcase_13 AC 12 ms
4,384 KB
testcase_14 AC 32 ms
5,372 KB
testcase_15 AC 10 ms
4,380 KB
testcase_16 AC 16 ms
4,380 KB
testcase_17 AC 12 ms
4,376 KB
testcase_18 AC 13 ms
4,380 KB
testcase_19 AC 20 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

// Mod int
const int mod = 1000000007;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
typedef vector<mint> vm;
typedef vector<vm> vvm;
//



int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  char cmd;
  int n,m;
  ll k;
  cin >> m >> n >> k;
  cin >> cmd;
  VLL x(n);
  VLL y(m);
  rep(i,n) cin >>  x[i];
  rep(i,m) cin >> y[i];
  sort(all(x));
  sort(all(y));

  if(cmd == '+'){
    ll ans = 0;
    VLL yy;
    yy.push_back(-1e12);
    rep(i,m) yy.push_back(y[i]);
    rep(i,n) {
      ll less  = k-x[i];
      if(less <= 0) {
        ans += m;
        continue;
      }
      ll outCnt = (lower_bound(all(yy),less) - yy.begin()) - 1;
      ans += m - outCnt ;
    }
    cout << ans << endl;
  }else{
    ll ans = 0;
    VLL yy;
    yy.push_back(-1e12);
    rep(i,m) yy.push_back(y[i]);
    rep(i,n) {
      if(x[i] >= k) {
        ans += m;
        continue;
      }
      ll less  = (k+x[i]-1)/x[i];
      ll outCnt = (lower_bound(all(yy),less) - yy.begin()) - 1;
      ans += m - outCnt ;
    }
    cout << ans << endl;
  }

  return 0;
}
0