結果
問題 |
No.2008 Super Worker
|
ユーザー |
![]() |
提出日時 | 2025-09-26 01:14:48 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 70 ms / 2,000 ms |
コード長 | 863 bytes |
コンパイル時間 | 9,336 ms |
コンパイル使用メモリ | 218,456 KB |
実行使用メモリ | 14,088 KB |
最終ジャッジ日時 | 2025-09-26 01:15:00 |
合計ジャッジ時間 | 10,795 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; struct D { long long a, b; double key; D(long long a_, long long b_) : a(a_), b(b_) { key = (double)(b - 1) / a; } }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector<long long> A(N), B(N); for (int i = 0; i < N; i++) cin >> A[i]; for (int i = 0; i < N; i++) cin >> B[i]; vector<D> ds; for (int i = 0; i < N; i++) { ds.emplace_back(A[i], B[i]); } sort(ds.begin(), ds.end(), [](const D &d1, const D &d2) { return d1.key > d2.key; // Pythonの reverse=True に対応 }); long long x = 1; long long ans = 0; for (auto &d : ds) { ans = (ans + d.a * x % MOD) % MOD; x = d.b * x % MOD; } cout << ans << "\n"; return 0; }