QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#319146 | #7750. Revenge on My Boss | Djangle162857 | WA | 124ms | 9824kb | C++14 | 1.4kb | 2024-02-01 23:37:52 | 2024-02-01 23:37:53 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << " == " << x << endl
#define el '\n'
typedef long long ll;
typedef long double ld;
const int mod = 1000000007;
const int inf = 2147483647;
const int N = 100020;
int a[N], b[N], c[N], n;
ll B;
struct Data {
ll d;
ld e;
int id;
} d[N];
vector<int> check(ll p) {
ll sum = 0;
vector<int> ans;
ans.resize(n + 1);
for (int i = 1; i <= n; i++) {
d[i].d = a[i] - b[i];
sum += d[i].d;
d[i].e = p * 1.0 / c[i] - B + a[i];
d[i].id = i;
}
sort(d + 1, d + n + 1, [&](const Data &x, const Data &y) {
if (x.d <= 0 && y.d <= 0)
return x.e > y.e;
if (x.d <= 0 || y.d <= 0)
return x.d < y.d;
return x.d + x.e < y.d + y.e;
});
sum = 0;
for (int i = 1; i <= n; i++) {
ans[i] = d[i].id;
if (d[i].e < sum) {
ans[0] = -1;
break;
}
sum += d[i].d;
}
return ans;
}
void solve() {
cin >> n;
B = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i] >> b[i] >> c[i];
B += b[i];
}
ll l = 1, r = 400;
vector<int> now;
while (l < r) {
ll mid = (l + r) >> 1;
now = check(mid);
if (now[0] != -1)
r = mid;
else
l = mid + 1;
}
now = check(r);
for (int i = 1; i <= n; i++) {
cout << now[i] << " ";
}
cout << el;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int T = 1;
cin >> T;
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3656kb
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 1 2 4 3 4 8 2 5 9 7 1 6
result:
ok correct
Test #2:
score: -100
Wrong Answer
time: 124ms
memory: 9824kb
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:
43248 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer Integer parameter [name=pi] equals to 0, violates the range [1, 100000]