QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#641227 | #9442. Music Game | crimsonsunset# | WA | 4ms | 3696kb | C++20 | 1.2kb | 2024-10-14 19:18:31 | 2024-10-14 19:18:31 |
Judging History
answer
#pragma GCC optimize("O3,unroll-loops,inline")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
constexpr int mod = 998244353;
int bp(int a, int b = mod - 2) {
if (b == 0)
return 1;
int c = bp(a, b / 2);
c = 1ll * c * c % mod;
if (b % 2)
c = 1ll * c * a % mod;
return c;
}
void solve() {
int n;
cin >> n;
vector<pair<pair<int, int>, int>> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i].ss >> a[i].ff.ff >> a[i].ff.ss;
}
sort(all(a), [&](pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
auto t1 = a.ss, t2 = b.ss;
auto a1 = a.ff.ff, b1 = a.ff.ss, a2 = b.ff.ff, b2 = b.ff.ss;
long double r1 = 1.0 * t1 * b1 / a1 * b2 / a2 + t2 * b2 / a2, r2 = 1.0 * t2 * b2 / a2 * b1 / a1 + t1 * b1 / a1;
return r1 < r2;
});
int ans = 0;
for (auto i: a)
ans = 1ll * (ans + i.ss) * i.ff.ss % mod * bp(i.ff.ff) % mod;
cout << ans << endl;
}
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
int t = 1;
// cin >> t;
while (t--)
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3532kb
input:
2 3 3 5 2 4 7
output:
831870305
result:
ok "831870305"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
5 2 5 9 6 4 7 1 9 14 17 8 13 10 4 11
output:
914017655
result:
ok "914017655"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
8 6 2 8 3 1 8 5 30 71 7 9 58 6 4 7 6 9 25 2 8 67 6 6 55
output:
923892723
result:
ok "923892723"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
2 2 2 3 1 5 6
output:
399297746
result:
ok "399297746"
Test #5:
score: -100
Wrong Answer
time: 4ms
memory: 3696kb
input:
6057 598846 477861 477861 355457 471360 471360 52553 53505 53505 910434 715394 957062 829770 396343 396343 388604 220815 628584 697515 339144 976739 134698 713562 713562 103516 548592 976096 328488 131879 979654 360558 458803 458803 609012 481090 852195 207954 434215 434215 74492 313219 453266 11312...
output:
195824308
result:
wrong answer 1st words differ - expected: '209793398', found: '195824308'