QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#649802 | #7750. Revenge on My Boss | Lavender_Field | WA | 669ms | 7288kb | C++20 | 1.6kb | 2024-10-18 10:31:51 | 2024-10-18 10:31:52 |
Judging History
answer
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define ROF(i,a,b) for(int i = a; i >= b; --i)
typedef long long ll;
using namespace std;
inline int rd() {
int r = 0; bool w = false; char ch = getchar();
while( ch < '0' || ch > '9' ) w = !(ch^45), ch = getchar();
while( ch >= '0' && ch <= '9' ) r = (r<<1) + (r<<3) + (ch^48), ch = getchar();
return w ? -r : r;
}
#define MAXN 100000
const ll INF = 1e18;
int n;
int a[MAXN+5], b[MAXN+5], c[MAXN+5];
int otp[MAXN+5], out[MAXN+5];
ll B, sum;
struct node {
double e;
int d, id;
}arr[MAXN+5];
bool cmp(const node &a , const node &b) {
if( (a.d > 0) ^ (b.d > 0) ) return (a.d > 0) < (b.d > 0);
if( a.d <= 0 ) return a.e > b.e;
return a.e - a.d < b.e - b.d;
}
bool chk( ll x ) {
ll now = 0;
FOR(i,1,n) arr[i].e = (double)x / c[i] - b[i] - B, arr[i].d = a[i] - b[i], arr[i].id = i;
sort(arr+1, arr+1+n, cmp);
FOR(i,1,n) {
now += arr[i].d;
if( now > arr[i].e ) return 0;
}
FOR(i,1,n) otp[i] = arr[i].id;
return 1;
}
void solve() {
B = 0, sum = 0;
n = rd();
FOR(i,1,n) a[i] = rd(), b[i] = rd(), c[i] = rd(), B += b[i], sum += a[i] - b[i];
ll l = 0, r = INF, ans = 0;
while( l <= r ) {
ll mid = (l + r) >> 1;
if( chk(mid) ) {
r = mid - 1;
ans = mid;
FOR(i, 1, n) out[i] = otp[i];
} else l = mid + 1;
}
// printf("%lld\n", ans);
FOR(i,1,n) printf("%d ",out[i]);
putchar('\n');
}
int main() {
int T = rd(); while( T-- ) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5860kb
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: 669ms
memory: 7288kb
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