QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#613190 | #9442. Music Game | ucup-team918# | WA | 2ms | 5708kb | C++17 | 2.2kb | 2024-10-05 13:43:31 | 2024-10-05 13:43:33 |
Judging History
answer
#include <bits/stdc++.h>
#define cerr cout << "in " << __LINE__ << "\t: "
using namespace std;
const int mod = 998244353;
struct mint {
int x;
mint() : x(0) {}
mint(long long y, bool flag = 0) {
if (flag) x = y;
else x = (y % mod + mod) % mod;
}
friend const mint ksm(mint a, long long b);
const mint inv() {return ksm(*this, mod - 2);}
};
bool operator == (const mint a, const mint b) {return a.x == b.x;}
bool operator != (const mint a, const mint b) {return a.x != b.x;}
bool operator < (const mint a, const mint b) {return a.x < b.x;}
int operator ! (const mint a) {return !a.x;}
const mint operator + (const mint a, const mint b) {
mint res(a.x + b.x, 1);
if (res.x >= mod) res.x -= mod;
return res;
}
mint& operator += (mint &a, const mint b) {
a.x += b.x;
if (a.x >= mod) a.x -= mod;
return a;
}
const mint operator - (const mint a, const mint b) {
mint res(a.x - b.x, 1);
if (res.x < 0) res.x += mod;
return res;
}
mint& operator -= (mint &a, const mint b) {
a.x -= b.x;
if (a.x < 0) a.x += mod;
return a;
}
const mint operator * (const mint a, const mint b) {
return mint((long long)a.x * b.x % mod, 1);
}
mint& operator *= (mint &a, const mint b) {
a.x = (long long)a.x * b.x % mod;
return a;
}
const mint ksm(mint a, long long b) {
mint res(1, 1);
for (; b; a *= a, b >>= 1)
if (b & 1) res *= a;
return res;
}
const mint operator / (const mint a, const mint b) {
return a * ksm(b, mod - 2);
}
mint& operator /= (mint &a, const mint b) {
a = a * ksm(b, mod - 2);
return a;
}
ostream& operator << (ostream &out, const mint a) {
return out << a.x;
}
istream& operator >> (istream &in, mint &a) {
long long y;
in >> y, a = mint(y);
return in;
}
int n, t[200010], a[200010], b[200010], p[200010];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++)
cin >> t[i] >> a[i] >> b[i], p[i] = i;
sort(p + 1, p + n + 1, [&](int x, int y) {
return t[y] * b[y] * (b[x] - a[x]) > t[x] * b[x] * (b[y] - a[y]);
});
mint sum = 1, ans = 0;
for (int i = n; i >= 1; i--)
sum *= mint(b[p[i]]) / a[p[i]], ans += t[p[i]] * sum;
cout << ans << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5708kb
input:
2 3 3 5 2 4 7
output:
831870305
result:
ok "831870305"
Test #2:
score: 0
Accepted
time: 1ms
memory: 5636kb
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: 3604kb
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: 3580kb
input:
2 2 2 3 1 5 6
output:
399297746
result:
ok "399297746"
Test #5:
score: -100
Wrong Answer
time: 2ms
memory: 3760kb
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:
45259523
result:
wrong answer 1st words differ - expected: '209793398', found: '45259523'