結果

問題 No.2008 Super Worker
ユーザー misty1999misty1999
提出日時 2022-07-15 21:39:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 6,152 bytes
コンパイル時間 2,220 ms
コンパイル使用メモリ 183,988 KB
実行使用メモリ 26,476 KB
最終ジャッジ日時 2024-06-27 17:12:12
合計ジャッジ時間 4,701 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
14,928 KB
testcase_01 AC 5 ms
15,212 KB
testcase_02 AC 7 ms
15,020 KB
testcase_03 AC 7 ms
15,128 KB
testcase_04 AC 6 ms
15,060 KB
testcase_05 AC 6 ms
15,056 KB
testcase_06 AC 6 ms
15,084 KB
testcase_07 AC 6 ms
15,108 KB
testcase_08 AC 7 ms
15,116 KB
testcase_09 AC 6 ms
15,188 KB
testcase_10 AC 7 ms
15,104 KB
testcase_11 AC 6 ms
15,060 KB
testcase_12 AC 6 ms
15,152 KB
testcase_13 AC 6 ms
15,256 KB
testcase_14 AC 5 ms
15,176 KB
testcase_15 AC 6 ms
15,260 KB
testcase_16 AC 6 ms
15,244 KB
testcase_17 AC 6 ms
15,184 KB
testcase_18 AC 6 ms
15,216 KB
testcase_19 AC 7 ms
15,204 KB
testcase_20 AC 6 ms
15,176 KB
testcase_21 AC 6 ms
15,208 KB
testcase_22 AC 5 ms
15,340 KB
testcase_23 AC 80 ms
26,472 KB
testcase_24 AC 81 ms
26,468 KB
testcase_25 AC 82 ms
26,344 KB
testcase_26 AC 82 ms
26,348 KB
testcase_27 AC 82 ms
26,344 KB
testcase_28 AC 89 ms
26,476 KB
testcase_29 AC 90 ms
26,348 KB
testcase_30 AC 88 ms
26,472 KB
testcase_31 AC 88 ms
26,472 KB
testcase_32 AC 89 ms
26,340 KB
testcase_33 AC 71 ms
26,340 KB
testcase_34 AC 89 ms
26,472 KB
testcase_35 AC 61 ms
26,472 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'void cl(T& ...)':
main.cpp:113:36: warning: fold-expressions only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
  113 | void cl(T &...t) { (..., (t.clear())); }
      |                                    ^
main.cpp: In function 'void in(T& ...)':
main.cpp:115:35: warning: fold-expressions only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
  115 | void in(T &...t) { (..., (cin >> t)); }
      |                                   ^

ソースコード

diff #

#include <bits/stdc++.h>
#define endl "\n"
#define stoi stoll
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")
#pragma comment(linker, "/stack:200000000")
#define overload4(_1, _2, _3, _4, name, ...) name
#define overload3(_1, _2, _3, name, ...) name
#define rep1(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for (ll i = n; i--;)
#define rrep2(i, n) for (ll i = n; i--;)
#define rrep3(i, b, a) for (ll i = b; i-- > (a);)
#define rrep4(i, b, a, c) \
  for (ll i = (a) + ((b) - (a)-1) / (c) * (c); i >= (a); i -= c)
#define rrep(...) \
  overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define elif else if
ll beki(ll i)
{
  return 1ll << i;
}
#define all(v) v.begin(), v.end()
#define allm(x, y, M) for (auto [(x), (y)] : (M))
#define alls(i, S) for (auto(&i) : (S))
#define pb push_back
#define fi first
#define se second
#define escape(a) \
  print(a);       \
  return;
const ll INF = (1LL << 61) - 1;
const ll MAX_N1 = 200010;
const ll MAX_N2 = 500010;
ll min(int x, ll y) { return min(ll(x), y); }
ll min(ll x, int y) { return min(x, ll(y)); }
ll max(int x, ll y) { return max(ll(x), y); }
ll max(ll x, int y) { return max(x, ll(y)); }
ld DIV(ll x, ll y) { return ld(x) / ld(y); }
template <class X>
void print(X x) { cout << x << endl; }
template <class X>
void printt(X x) { cout << x; }
void print(vl x)
{
  for (ll i : x)
  {
    cout << i << " ";
  }
  cout << endl;
}
template <class X>
vector<X> ruiseki(vector<X> &A)
{
  vector<X> P;
  P.pb(0);
  for (X i : A)
  {
    P.pb(P.back() + i);
  }
  return P;
}
template <class X>
vector<X> printpart(vector<X> &A, ll x, ll y)
{
  rep(i, x, y + 1) { cout << A[i] << " "; }
  print("");
}
void print(vector<PP> x)
{
  for (PP i : x)
  {
    cout << i.first << " " << i.second << endl;
  }
  cout << endl;
}
template <class X>
int lbound(vector<X> &Y, X a)
{
  return lower_bound(all(Y), a) - Y.begin();
}
template <class X>
int ubound(vector<X> &Y, X a)
{
  return upper_bound(all(Y), a) - Y.begin();
}
template <class X>
X lbound2(vector<X> &Y, X a, int mode = 0)
{
  int x = lbound(Y, a) - mode;
  if (x < 0 || x >= Y.size())
    return INF;
  return Y[x];
}
template <class X>
X ubound2(vector<X> &Y, X a, int mode = 0)
{
  int x = ubound(Y, a) - mode;
  if (x < 0 || x >= Y.size())
    return INF;
  return Y[x];
}
template <class... T>
void cl(T &...t) { (..., (t.clear())); }
template <class... T>
void in(T &...t) { (..., (cin >> t)); }
template <class... T>
void put(vl &V, int n, int mode = 0)
{
  ll k;
  if (mode == 0)
    cl(V);
  rep(i, n)
  {
    cin >> k;
    V.pb(k);
  }
}
int max_index(vl &V) { return max_element(all(V)) - V.begin(); }
int min_index(vl &V) { return min_element(all(V)) - V.begin(); }
ll sum(vl &V) { return accumulate(all(V), 0ll); }
template <typename T>
void UNIQUE(vector<T> &v)
{
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
}
template <typename T>
T ADD(T a, T b)
{
  T res;
  return __builtin_add_overflow(a, b, &res) ? numeric_limits<T>::max() : res;
}
template <typename T>
T MUL(T a, T b)
{
  T res;
  return __builtin_mul_overflow(a, b, &res) ? numeric_limits<T>::max() : res;
};
template <typename T>
T POW(T a, int n)
{
  T res = 1;
  for (; n > 0; n >>= 1, a *= a)
    if (n & 1)
      res *= a;
  return res;
}
template <class X>
bool ma(X &a, X b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class X>
bool mi(X &a, X b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
void vset(vl &A, ll n, ll k) { A = vl(n, k); }
ll divup(ll x, ll y) { return (x + y - 1) / y; }
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, m, u, v;
ll codeforces = 1;
const ll mod = 1000000007;
// const ll mod = 998244353;
vl g[MAX_N2];
vector<PP> VP, VP2;
string S, T, U;
vl A, B, C, D;
struct mint
{
  using ull = unsigned long long int;
  ull v;
  mint(ll vv = 0) { s(vv % mod + mod); }
  mint &s(ull vv)
  {
    v = vv < mod ? vv : vv - mod;
    return *this;
  }
  //オーバーロード
  mint operator-() const { return mint() - *this; } // mint型にキャスト
  mint &operator+=(const mint &val) { return s(v + val.v); }
  mint &operator-=(const mint &val) { return s(v + mod - val.v); }
  mint &operator*=(const mint &val)
  {
    v = ull(v) * val.v % mod;
    return *this;
  }
  mint &operator/=(const mint &val) { return *this *= val.inv(); }
  mint operator+(const mint &val) { return mint(*this) += val; }
  mint operator-(const mint &val) { return mint(*this) -= val; }
  mint operator*(const mint &val) { return mint(*this) *= val; }
  mint operator/(const mint &val) { return mint(*this) /= val; }
  mint pow(ll n) const
  {
    mint res(1), x(*this);
    while (n)
    {
      if (n & 1)
        res *= x;
      x *= x;
      n >>= 1ll;
    }
    return res;
  }
  mint inv() const { return pow(mod - 2); }
  //拡張ユークリッドの互除法
  /* mint inv()const{
  int x,y;
  int g=extgcd(v,mod,x,y);
  assert(g==1);
  if(x<0)x+=mod;
  return mint(x);
  }*/
  friend ostream &operator<<(ostream &os, const mint &val)
  {
    return os << val.v;
  } //出力
  bool operator<(const mint &val) const { return v < val.v; }
  bool operator==(const mint &val) const { return v == val.v; }
  bool operator>(const mint &val) const { return v > val.v; }
};
typedef vector<mint> vm;
void solve()
{
  in(n);
  put(A, n);
  put(B, n);
  vector<pair<long double, ll>> VD;
  rep(i, n)
  {
    VD.pb({DIV(B[i] - 1, A[i]), i});
  }
  sort(all(VD));
  reverse(all(VD));
  mint a = 1, ans = 0;
  rep(i, n)
  {
    ans += a * A[VD[i].se];
    a *= B[VD[i].se];
  }
  print(ans.v);
}
int main()
{
  cout << fixed << setprecision(15);
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cin >> codeforces;
  rep(i, codeforces)
  {
    ans = 0;
    solve();
  }
}
0