QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#649761 | #7750. Revenge on My Boss | Lavender_Field | RE | 1ms | 3824kb | C++20 | 1.6kb | 2024-10-18 10:03:54 | 2024-10-18 10:03:55 |
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 100
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.d + a.e < b.d + b.e;
}
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: 3824kb
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
Runtime Error
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...