QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#266333#7750. Revenge on My Bossmendicillin2#WA 1ms5468kbC++17980b2023-11-26 13:03:532023-11-26 13:03:55

Judging History

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

  • [2023-11-26 13:03:55]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5468kb
  • [2023-11-26 13:03:53]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long

const int N=1e5+5;
int n;
int a[N],b[N],c[N];
struct node{
	int id,a,b,s;
}re[N];

inline bool cmp(node x,node y)
{
	return x.a+y.b<x.b+y.a;
}

int pre[N],suf[N];
inline bool check(int x)
{
	for(int i=1;i<=n;i++) re[i].id=i, re[i].a=a[i], re[i].b=b[i], re[i].s=x/c[i];
	sort(re+1,re+n+1,cmp);
	pre[0]=suf[n+1]=0;
	for(int i=1;i<=n;i++) pre[i]=pre[i-1]+re[i].a;
	for(int i=n;i>=1;i--) suf[i]=suf[i+1]+re[i].b;
	for(int i=1;i<=n;i++)
		if(pre[i]+suf[i]-re[i].s>0)
			return false;
	return true;
}

signed main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	int T;
	cin>>T;
	while(T--)
	{
		cin>>n;
		for(int i=1;i<=n;i++) cin>>a[i]>>b[i]>>c[i];
		int lef=0, rig=1e18;
		while(lef<rig)
		{
			int mid=(lef+rig)>>1;
			if(check(mid)) rig=mid;
			else lef=mid+1;
		}
		check(lef);
		for(int i=1;i<=n;i++) cout<<re[i].id<<" ";
		cout<<"\n";
	}
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5468kb

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

result:

wrong answer Wrong Answer on Case#1