QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#620674#7750. Revenge on My BossxinlengweishangTL 0ms0kbC++201.1kb2024-10-07 20:18:492024-10-07 20:18:52

Judging History

你现在查看的是最新测评结果

  • [2024-10-07 20:18:52]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-10-07 20:18:49]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define maxn 1000010
using namespace std;
struct node{
	ll a,b,c,d,e;
	ll num;
}w[maxn];
bool cmp(node x,node y){
	if(x.d<=0&&y.d<=0)
		return x.e>y.e;
	else if(x.d<=0||y.d<=0)
		return x.d<y.d;
	else 
		return x.d+x.e<y.d+y.e;
}
void slove(){
	ll n,B=0;
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++){
		scanf("%lld%lld%lld",&w[i].a,&w[i].b,&w[i].c);
		w[i].d=w[i].a-w[i].b;
		B+=w[i].b;
		w[i].num=i;
	}
	ll P;
	ll l=1,r=1000000000000000000ll;
	while(l+1<r){
		int temp=0;
	ll sumd=0;
	for(int i=1;i<=n;i++){
		if(sumd>w[i].e){
			temp=1;
			break;
		}
		sumd+=w[i].d;
	}
	if(temp) l=P;
	else r=P;
//	printf("%lld %lld %lld\n",P,l,r);
	}
//	printf("%lld\n",P);
		P=(l+r)/2;
	for(int i=1;i<=n;i++){
		w[i].e=P/w[i].c-B-w[i].a;
//		printf("%d %lld %lld %lld %lld %lld\n",i,w[i].a,w[i].b,w[i].c,w[i].d,w[i].e);
	}
	sort(w+1,w+n,cmp);
	for(int i=1;i<=n;i++){
		printf("%lld ",w[i].num);
	}
	printf("\n");
	return ;
}
int main(){
	int T;
	scanf("%d",&T);
	while(T--){
	    slove();
	}
	return 0; 
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

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:


result: