結果

問題 No.2008 Super Worker
ユーザー srjywrdnprkt
提出日時 2023-05-13 07:48:02
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 168 ms / 2,000 ms
コード長 832 bytes
コンパイル時間 1,142 ms
コンパイル使用メモリ 112,224 KB
最終ジャッジ日時 2025-02-12 23:52:24
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;

bool ord(pair<ll, ll> &x, pair<ll, ll> &y){
    return x.first - y.first + y.first * x.second - x.first * y.second > 0;
}

const ll modc = 1e9+7;

int main(){

    ll N, ans=0, lv=1, a, b;
    cin >> N;
    vector<pair<ll, ll>> AB(N);
    for (int i=0; i<N; i++) cin >> AB[i].first;
    for (int i=0; i<N; i++) cin >> AB[i].second;
    sort(AB.begin(), AB.end(), ord);

    for (int i=0; i<N; i++){
        tie(a, b) = AB[i];
        ans += (lv * a) % modc;
        ans %= modc;
        lv = (lv * b);
        lv %= modc;
    }

    cout << ans << endl;

    return 0;
}
0