QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#620820 | #7750. Revenge on My Boss | warner1129 | WA | 223ms | 8340kb | C++20 | 2.9kb | 2024-10-07 21:34:51 | 2024-10-07 21:34:52 |
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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
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: 223ms
memory: 8340kb
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