QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#657636 | #9442. Music Game | ucup-team1001# | WA | 0ms | 3624kb | C++23 | 1.2kb | 2024-10-19 15:07:53 | 2024-10-19 15:07:53 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
using i64 = long long;
i64 mod = 998244353;
i64 mul(i64 a, i64 b) {
return a * b % mod;
}
i64 qpow(i64 a, i64 b) {
i64 res = 1;
while (b) {
if (b & 1) res = mul(res, a);
b /= 2;
a = mul(a, a);
}
return res;
}
i64 inv(i64 x) {
return qpow(x, mod - 2);
}
i64 add(i64 x, i64 y) {
return (x + y) % mod;
}
i64 sub(i64 x, i64 y) {
return (x - y + mod) % mod;
}
void solve() {
int n;
cin >> n;
vector<tuple<i64, i64, i64>> arr;
for (int i = 1; i <= n; i++) {
int x, y, z;
cin >> x >> y >> z;
arr.emplace_back(x, y, z);
}
sort(arr.begin(), arr.end(), [&](auto a, auto b) {
auto [x1, y1, z1] = a;
auto [x2, y2, z2] = b;
return x1 * z1 * y2 < x2 * z2 * y1;
});
i64 tim = 0;
for (auto [x, y, z]: arr) {
// cerr << x << " " << y << " " << z << endl;
swap(y, z);
tim = mul((mul(y, inv(z))),
add(tim, x));
}
cout << tim << endl;
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
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: 3560kb
input:
2 3 3 5 2 4 7
output:
831870305
result:
ok "831870305"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3624kb
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: -100
Wrong Answer
time: 0ms
memory: 3564kb
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:
173088720
result:
wrong answer 1st words differ - expected: '923892723', found: '173088720'