QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#288021 | #7750. Revenge on My Boss | yllcm | WA | 0ms | 3732kb | C++20 | 1.6kb | 2023-12-21 16:10:03 | 2023-12-21 16:10:05 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define db double
#define ull unsigned long long
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define FR first
#define SE second
#define int long long
using namespace std;
inline int read() {
int x = 0; bool op = false;
char c = getchar();
while(!isdigit(c))op |= (c == '-'), c = getchar();
while(isdigit(c))x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
return op ? -x : x;
}
const int N = 1e5 + 10;
int n;
int a[N], b[N], c[N];
void solve() {
n = read();
vector<int> A, B;
for(int i = 1; i <= n; i++) {
a[i] = read(); b[i] = read(); c[i] = read();
(a[i] < b[i] ? A : B).eb(i);
}
int lef = 0, rig = 1e12;
auto chk = [&](int X) {
sort(A.begin(), A.end(), [&](int x, int y) {return X / c[x] - a[x] > X / c[y] - a[y];});
int sum = 0;
for(int i = 1; i <= n; i++)sum += b[i];
for(int x : A) {
if(sum + a[x] > X / c[x])return false;
sum -= b[x]; sum += a[x];
}
sum = 0;
for(int i = 1; i <= n; i++)sum += a[i];
sort(B.begin(), B.end(), [&](int x, int y) {return X / c[x] - b[x] > X / c[y] - b[y];});
for(int x : B) {
if(sum + b[x] > X / c[x])return false;
sum -= a[x]; sum += b[x];
}
return true;
};
while(lef + 1 < rig) {
int mid = lef + rig >> 1;
if(chk(mid))rig = mid;
else lef = mid;
}
cout << rig << endl;
reverse(B.begin(), B.end());
A.insert(A.end(), B.begin(), B.end());
for(int x : A)printf("%lld ", x); putchar('\n');
return ;
}
signed main() {
int test = read();
while(test--)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3732kb
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:
80 3 2 1 4 297 3 8 4 2 5 9 7 1 6
result:
wrong answer Integer parameter [name=pi] equals to 80, violates the range [1, 4]