QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#628840#7750. Revenge on My BosslixpWA 0ms3776kbC++141.2kb2024-10-10 22:40:182024-10-10 22:40:19

Judging History

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

  • [2024-10-10 22:40:19]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3776kb
  • [2024-10-10 22:40:18]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+10;
int n,S,f[N],sum[N];
struct node {
	int a,b,c,d,id;
	double e;
	bool operator < (const node &x) const {
		if((d<=0) ^ (x.d<=0)) return d<x.d;
		if((d<=0) && (x.d<=0)) return e>x.e;
		return d+e<x.d+x.e;
	}
} p[N];

bool check(int T) {
	for(int i=1;i<=n;i++)
		p[i].e=(long double)T/p[i].c-p[i].b-S;
	sort(p+1,p+n+1);
	for(int i=1;i<=n;i++) f[i]=p[i].id;
	int mx=0;
	for(int i=1;i<=n;i++) {
		mx=max(mx,(S+sum[i]+p[i].b)*p[i].c);
	}
	return mx<=T;
}

void solve() {
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) {
		scanf("%lld%lld%lld",&p[i].a,&p[i].b,&p[i].c);
		S+=p[i].b;p[i].d=p[i].a-p[i].b; sum[i]=sum[i-1]+p[i].d;
		p[i].id=i;
	}
	int l=1,r=1e18,ans;
	while(l<=r) {
		int mid=(l+r)>>1;
		if(check(mid)) r=mid-1,ans=mid;
		else l=mid+1;
	}
	check(ans);
	cout<<ans<<"?   ";
	for(int i=1;i<=n;i++) cout<<f[i]<<" "; cout<<"\n";
}

void init() {
	S=0;
}
signed main() {
	int T;scanf("%lld",&T);
	while(T--) {
		init(); solve();
	}
	return 0;
} 

/*
1
10
2 10 1
8 10 6
4 4 9
6 7 5
5 6 4
7 10 9
7 7 7
4 9 6
4 5 7
1 1 7

1 5 4 8 2 10 9 7 3 6 
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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:

96?   3 1 2 4 
351?   3 4 8 2 5 9 7 1 6 

result:

wrong output format Expected integer, but "96?" found