QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#749141 | #7750. Revenge on My Boss | bbc_ouo | WA | 0ms | 5704kb | C++20 | 1.8kb | 2024-11-14 22:49:05 | 2024-11-14 22:49:06 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 9;
int n, ans[maxn], T;
long long sum = 0;
int pos;
struct node
{
long long a, b, c;
} t[maxn];
struct node2
{
long long d, e;
int id;
} tt[maxn];
bool cmp(node2 t1, node2 t2)
{
return t1.d < t2.d;
}
bool cmp2(node2 t1, node2 t2)
{
return t1.e >= t2.e;
}
bool cmp3(node2 t1, node2 t2)
{
return t1.d + t1.e <= t2.d + t2.e;
}
int check(long long x)
{
for (int i = 1; i <= n; i++)
{
tt[i].id = i, tt[i].d = t[i].a - t[i].b, tt[i].e = x / t[i].c - t[i].a - sum;
}
if (pos == -1)
{
sort(tt + 1, tt + n + 1, cmp);
pos = n + 1;
for (int i = 1; i <= n; i++)
{
if (tt[i].d >= 0)
{
pos = i;
break;
}
}
}
sort(tt + 1, tt + pos, cmp2);
if (pos <= n)
{
sort(tt + pos, tt + n + 1, cmp3);
}
long long pre = 0;
for (int i = 1; i <= n; i++)
{
if (pre > tt[i].e)
return 0;
pre += tt[i].d;
}
for (int i = 1; i <= n; i++)
ans[i] = tt[i].id;
return 1;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> T;
while (T--)
{
sum = 0;
cin >> n;
pos = -1;
for (int i = 1; i <= n; i++)
cin >> t[i].a >> t[i].b >> t[i].c, sum += t[i].b;
long long l = 0, r = 1e18;
while (l < r)
{
long long mid = (l + r) >> 1;
if (check(mid))
r = mid;
else
l = mid + 1;
}
check(l);
for (int i = 1; i <= n; i++)
cout << ans[i] << " \n"[i == n];
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 5704kb
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:
1 2 3 4 1 3 4 2 5 8 9 7 6
result:
wrong answer Wrong Answer on Case#1