QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#262021 | #7750. Revenge on My Boss | zlxFTH | WA | 1ms | 5456kb | C++17 | 1.5kb | 2023-11-23 14:47:46 | 2023-11-23 14:47:46 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i, a, b) for (auto cc##i = (b), i = (a); i <= cc##i; ++i)
#define per(i, a, b) for (auto cc##i = (b), i = (a); i >= cc##i; --i)
#define fi first
#define se second
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
typedef long long LL;
const int N = 1e5 + 5;
int n;
int p[N];
LL B, a[N], b[N], c[N], d[N], e[N];
bool check(LL Lim) {
rep(i, 1, n) {
e[i] = Lim / c[i] - a[i] - B;
}
int tp = 0;
rep(i, 1, n) {
if (d[i] <= 0) p[++tp] = i;
}
rep(i, 1, n) {
if (d[i] > 0) p[++tp] = i;
}
sort(p + 1, p + tp + 1, [&](auto x, auto y) {
return e[x] > e[y];
});
sort(p + tp + 1, p + n + 1, [&](auto x, auto y) {
return e[x] + d[x] < e[y] + d[y];
});
LL sum = 0;
rep(i, 1, n) {
int u = p[i];
if (sum > e[u]) {
return 0;
}
sum += d[u];
}
return 1;
}
void solve() {
B = 0;
cin >> n;
rep(i, 1, n) {
cin >> a[i] >> b[i] >> c[i];
d[i] = a[i] - b[i];
B += b[i];
}
LL l = 0, r = 1e18;
while (l < r) {
LL mid = (l + r) / 2;
if (check(mid)) r = mid;
else l = mid + 1;
}
check(l);
rep(i, 1, n) {
cout << p[i] << " \n"[i == n];
}
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int t;
cin >> t;
while (t--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5456kb
input:
2 4 1 1 4 5 1 5 1 9 1 9 8 1 9 3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 8 3 2 7
output:
3 4 1 2 6 1 3 7 9 8 4 2 5
result:
wrong answer Wrong Answer on Case#1