QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#720807 | #7750. Revenge on My Boss | ucup-team5217# | WA | 425ms | 8592kb | C++23 | 1.5kb | 2024-11-07 14:12:19 | 2024-11-07 14:12:19 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 10;
const double eps = 1e-10;
int n;
int a[N], b[N], c[N];
int sb;
struct Node {
int a, c, id;
}p[N];
bool check(int k) {
int tot = 0;
for (int i = 1; i <= n; ++i) {
if (a[i] - b[i] < 0) {
p[++tot] = (Node){a[i] - b[i], k / c[i] - (b[i] + sb), i};
}
}
int mid = tot;
for (int i = 1; i <= n; ++i) {
if (a[i] - b[i] >= 0) {
p[++tot] = (Node){a[i] - b[i], k / c[i] - (b[i] + sb), i};
}
}
sort(p + 1, p + mid + 1, [](Node a, Node b) -> bool{
return a.c > b.c;
});
sort(p + mid + 1, p + tot + 1, [](Node a, Node b) -> bool {
return a.c < b.c;
});
int s = 0;
for (int i = 1; i <= n; ++i) {
s += (p[i].a);
if (s - p[i].c > eps) {
return 0;
}
}
return 1;
}
void solve() {
scanf("%lld", &n);
for (int i = 1; i <= n; ++i) {
scanf("%lld%lld%lld", &a[i], &b[i], &c[i]);
sb += b[i];
}
int l = 0, r = 2e18 + 1e17;
while (l < r) {
int mid = (l + r) >> 1;
if (check(mid)) r = mid;
else l = mid + 1;
}
check(l);
for (int i = 1; i <= n; ++i) {
printf("%lld ", p[i].id);
}
printf("\n");
// printf("%d\n", l);
}
signed main() {
int T;
scanf("%lld", &T);
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5968kb
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 2 1 4 3 4 8 2 5 9 7 1 6
result:
ok correct
Test #2:
score: -100
Wrong Answer
time: 425ms
memory: 8592kb
input:
1 100000 581297 102863 1 742857 42686 1 676710 233271 1 443055 491162 1 442056 28240 1 769277 331752 1 8608 369730 1 495112 525554 1 787449 938154 1 441186 850694 1 84267 925450 1 740811 32385 1 834021 37680 1 257878 564126 1 90618 914340 1 239641 463103 1 40687 343062 1 587737 458554 1 103684 48666...
output:
32063 35138 77895 37175 1117 78892 13855 93403 57307 43882 10790 40485 75847 86508 16681 30921 37548 74098 71155 60433 22241 74378 28602 30951 65092 98171 260 71472 73404 2098 26268 89359 83373 57 41825 24139 11373 63971 45598 22777 41079 27203 79576 94828 67086 63986 84460 6652 82720 32084 87144 88...
result:
wrong answer Wrong Answer on Case#1