QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#628841#7750. Revenge on My BosslixpWA 259ms9892kbC++141.2kb2024-10-10 22:40:352024-10-10 22:40:36

Judging History

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

  • [2024-10-10 22:40:36]
  • 评测
  • 测评结果:WA
  • 用时:259ms
  • 内存:9892kb
  • [2024-10-10 22:40:35]
  • 提交

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 
*/

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3688kb

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: 259ms
memory: 9892kb

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