QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#620830 | #7750. Revenge on My Boss | warner1129 | WA | 1ms | 3496kb | C++20 | 2.9kb | 2024-10-07 21:39:39 | 2024-10-07 21:39:39 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
template<class F, class S>
ostream &operator<<(ostream &s, const pair<F, S> &v) {
s << "(" << v.first << ", " << v.second << ")";
return s;
}
template<ranges::range T> requires (!is_convertible_v<T, string_view>)
istream &operator>>(istream &s, T &&v) {
for (auto &&x : v) s >> x;
return s;
}
template<ranges::range T> requires (!is_convertible_v<T, string_view>)
ostream &operator<<(ostream &s, T &&v) {
for (auto &&x : v) s << x << ' ';
return s;
}
#ifdef LOCAL
template<class... T> void dbg(T... x) {
char e{};
((cerr << e << x, e = ' '), ...);
}
#define debug(x...) dbg(#x, '=', x, '\n')
#else
#define debug(...) ((void)0)
#endif
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define ff first
#define ss second
template<class T> inline constexpr T inf = numeric_limits<T>::max() / 2;
bool chmin(auto &a, auto b) { return (b < a and (a = b, true)); }
bool chmax(auto &a, auto b) { return (a < b and (a = b, true)); }
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128;
using u128 = unsigned __int128;
constexpr i64 mod = 998244353;
void solve() {
int n;
cin >> n;
vector<i64> A(n), B(n), C(n), D(n);
for (int i = 0; i < n; i++) {
cin >> A[i] >> B[i] >> C[i];
D[i] = A[i] - B[i];
}
const i64 Bsum = reduce(all(B), 0LL);
vector<pair<i64, i64>> pa(n);
vector<int> ord(n);
iota(all(ord), 0);
auto check = [&](i64 P) -> bool {
for (int i = 0; i < n; i++) {
pa[i] = {D[i], P / C[i] - B[i] - Bsum};
}
sort(all(ord), [&](int i, int j) {
auto a = pa[i];
auto b = pa[j];
if (a.ff <= 0 and b.ff <= 0) {
return a.ss > b.ss;
}
if (a.ff > 0 and b.ff > 0) {
return a.ff + a.ss > b.ff + b.ss;
}
return (a.ff <= 0) > (b.ff <= 0);
return min(a.ss - a.ff, b.ss - a.ff - b.ff) > min(b.ss - b.ff, a.ss - a.ff - b.ff);
});
i64 sum = 0;
for (auto i : ord) {
auto [a, b] = pa[i];
sum += a;
if (sum > b) {
return false;
}
}
return true;
};
i64 ans = *ranges::partition_point(views::iota(0LL, (i64)1.1E18),
[&](i64 x) {
return !check(x);
});
check(ans);
for (int x : ord) {
cout << x + 1 << " \n"[x == ord.back()];
}
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
int t = 1;
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: 3496kb
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 4 2 3 4 8 2 6 1 7 9 5
result:
wrong answer Wrong Answer on Case#1