QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#270817#7750. Revenge on My BossHayasaWA 1ms3540kbC++201.1kb2023-12-01 15:17:412023-12-01 15:17:42

Judging History

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

  • [2023-12-01 15:17:42]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3540kb
  • [2023-12-01 15:17:41]
  • 提交

answer

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

using ll=long long;
const int M=1e5+10;
int ans[M],A[M],B[M],C[M],w[M];
vector<int>neg,pos;
int n;
ll sa[M],sb[M],D[M];
bool check(ll op){
	for(int i=1;i<=n;++i)
		D[i]=op/C[i]-sb[1]-B[i];
	sort(neg.begin(),neg.end(),[&](int i,int j){return D[i]-w[i]<D[j]-w[j];});

	sort(pos.begin(),pos.end(),[&](int i,int j){return D[i]<D[j];});
	ll sum=0;
	for(int x:neg){
		sum+=w[x];
		if(sum>D[x])return 0;
	}
	for(int x:pos){
		sum+=w[x];
		if(sum>D[x])return 0;
	}
	int cnt=0;
	for(int x:neg)ans[++cnt]=x;
	for(int x:pos)ans[++cnt]=x;
	return 1;
}
void solve(){
	scanf("%d",&n);
	pos.clear(),neg.clear();
	for(int i=1;i<=n;++i){
		scanf("%d%d%d",&A[i],&B[i],&C[i]);
		w[i]=A[i]-B[i];
		if(w[i]>=0)pos.push_back(i);
		else neg.push_back(i);
	}
	for(int i=1;i<=n;++i)sa[i]=sa[i-1]+A[i];
	sb[n+1]=0;
	for(int i=n;i>=1;--i)sb[i]=sb[i+1]+B[i];
	ll L=0,R=1e18,res=0;
	while(L<=R){
		ll mid=(L+R)>>1;
		if(check(mid))R=mid-1,res=mid;
		else L=mid+1;
	}
	for(int i=1;i<=n;++i)printf("%d ",ans[i]);
	puts("");
	//cout<<res<<endl;

}
	
int main(){
	cin.tie(nullptr)->sync_with_stdio(false);
	int T;
	cin>>T;
	while(T--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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:

wrong output format Unexpected end of file - int32 expected