QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#628855#7750. Revenge on My BosslixpWA 333ms10836kbC++141.0kb2024-10-10 22:45:142024-10-10 22:45:18

Judging History

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

  • [2024-10-10 22:45:18]
  • 评测
  • 测评结果:WA
  • 用时:333ms
  • 内存:10836kb
  • [2024-10-10 22:45:14]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+10;
int n,S,f[N];
struct node {
	int a,b,c,d,id;
	long 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=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 sum=0;
	for(int i=1;i<=n;i++) {
		sum+=p[i].d;
		if(sum-p[i].e>0) return false;
	}
	return true;	
}

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;
		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);
	if(n>=100) 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;
} 

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5688kb

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: 333ms
memory: 10836kb

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:

50052760223 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 32...

result:

wrong output format Expected int32, but "50052760223" found