QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#256096 | #7750. Revenge on My Boss | ucup-team346# | WA | 632ms | 9816kb | C++20 | 2.0kb | 2023-11-18 17:51:20 | 2023-11-18 17:51:21 |
Judging History
answer
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define REP(i,a,b) for(int i=a;i>=b;i--)
#define db double
#define ve vector<int>
#define pa pair<int,int>
#define fr first
#define sd second
#define pb push_back
#define mp make_pair
#define MEM(a) memset(a,0,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
inline ll read()
{
char ch = getchar();
ll s = 0, w = 1;
while (ch < '0' || ch > '9') {if (ch == '-')w = -1; ch = getchar();}
while (ch >= '0' && ch <= '9') {s = s * 10 + ch - '0'; ch = getchar();}
return s * w;
}
#define N 100010
#define int ll
int n, m;
int a[N], b[N], c[N];
int A[N], B[N];
int sb[N];
int p[N];
bool cmp1(int x, int y) {return B[x] > B[y];}
bool cmp2(int x, int y) {return B[x] < B[y];}
int check(int W)
{
for (int i = 1; i <= n; i ++)
{
A[i] = a[i] - b[i];
B[i] = W / c[i] - sb[n] - b[i];
}
vector<int>P, Q;
for (int i = 1; i <= n; i ++)if (A[i] <= 0)P.push_back(i); else Q.push_back(i);
sort(P.begin(), P.end(), cmp1); sort(Q.begin(), Q.end(), cmp2);
int tot = 0;
for (int x : P)p[++ tot] = x; for (int x : Q)p[++ tot] = x;
int sum = 0;
// cout << "??:" << W << endl;
// for (int i = 1; i <= n; i ++)cout << A[i] << ' '; cout << endl;
// for (int i = 1; i <= n; i ++)cout << B[i] << ' '; cout << endl;
for (int i = 1; i <= n; i ++)
{
sum += A[p[i]];
if (sum > B[p[i]])return 0;
}
return 1;
}
void sol()
{
cin >> n;
for (int i = 1; i <= n; i ++)cin >> a[i] >> b[i] >> c[i];
for (int i = 1; i <= n; i ++)sb[i] = sb[i - 1] + b[i];
check(80);
int l = 0, r = 1e18, ans = 1e18;
while (l <= r)
{
int mid = (l + r) >> 1;
if (check(mid))ans = mid, r = mid - 1;
else l = mid + 1;
}
check(ans);
// cout << ans << endl;
for (int i = 1; i <= n; i ++)
{
cout << p[i];
if (i == n)cout << '\n';
else cout << ' ';
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int T; cin >> T;
while (T --)sol();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 5464kb
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: 632ms
memory: 9816kb
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