QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#261444#7750. Revenge on My BossLogingWA 0ms1484kbC++201.1kb2023-11-22 21:47:372023-11-22 21:47:38

Judging History

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

  • [2023-11-22 21:47:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:1484kb
  • [2023-11-22 21:47:37]
  • 提交

answer

#include<cstdio>
#include<algorithm>
#define M 100005
using namespace std;
int sign(long long x){
	if(x<=0)return 0;
	return 1;
}
struct node{
	int id;
	long long a,b,c,d;
	double e;
	bool operator <(const node &_)const{
		if(sign(d)!=sign(_.d))return sign(d)<sign(_.d);
		if(d<=0)return e<_.e;
		return d+e<_.d+_.e;
	}
}A[M];
int n;
long long sumB;
bool check(long long x){
	for(int i=1;i<=n;i++)A[i].e=1.0*x/A[i].c-A[i].b-sumB;
	sort(A+1,A+n+1);
	long long sumd=0;
	for(int i=1;i<=n;i++){
		if(A[i].c*(sumB+sumd+A[i].b)>x)return false;
		sumd+=A[i].d;
	}
	return true;
}
int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		scanf("%d",&n);
		for(int i=1;i<=n;i++)scanf("%lld%lld%lld",&A[i].a,&A[i].b,&A[i].c);
		sumB=0;
		for(int i=1;i<=n;i++){
			A[i].id=i;
			sumB+=A[i].b;
			A[i].d=A[i].a-A[i].b;
		}
		long long L=0,R=1e18,res=1e18;
		while(L<=R){
			long long mid=(L+R)>>1;
			if(check(mid)){
				res=mid;
				R=mid-1;
			}else{
				L=mid+1;
			}
		}
		check(res);
//		printf("res=%lld\n",res);
		for(int i=1;i<=n;i++)printf("%d ",A[i].id);puts("");
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1484kb

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 3 2 4 
2 8 4 3 5 9 7 1 6 

result:

wrong answer Wrong Answer on Case#2