QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#270003#7750. Revenge on My Bosstime_interspace#WA 625ms6628kbC++201.2kb2023-11-30 13:39:442023-11-30 13:39:44

Judging History

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

  • [2023-11-30 13:39:44]
  • 评测
  • 测评结果:WA
  • 用时:625ms
  • 内存:6628kb
  • [2023-11-30 13:39:44]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j; i <= k; ++i)
#define repp(i,j,k) for(int i = j; i >= k;--i)
#define ll long long
int rd() {
	int x; scanf("%d",&x);
	return x;
}
int a[101000],b[101000],c[101000];
struct node{
	int d,id; double e;
}obj[101000];
int n;
ll B;
vector<int>ans;
bool cmp(node x,node y) {
	if( x.d <= 0 && y.d >= 0 ) return 1;
	else if( x.d >= 0 && y.d <= 0 ) return 0;
	else if( x.d < 0 && y.d < 0 ) return x.e > y.e;
	else return (x.e+x.d) < (y.e+y.d);
}
bool check(ll M) {
	rep(i,1,n) {
		obj[i].id = i;
		obj[i].d = a[i] - b[i];
		obj[i].e = 1.0*M/c[i] - B - a[i]; 
	}
	sort( obj+1 , obj+n+1 , cmp );
	ll res = 0;
	rep(i,1,n) {
		if( res > obj[i].e ) return false;
		res += obj[i].d;
	}
	return true;
}
void work() {
	B = 0;
	
	n = rd();
	rep(i,1,n) a[i] = rd() , b[i] = rd() , c[i] = rd() , B += b[i];
	ll l = 0 , r = 100000000000000000ll;
	while( l + 1 < r ) {
		ll mid = (l+r)>>1;
		if( check(mid) ) l = mid;
		else r = mid;
	}
	if( check(r) );
	else check(l);
	rep(i,1,n) printf("%d ",obj[i].id); printf("\n");
}
int main(){
	int T = rd();
	while(T--) work();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

result:

ok correct

Test #2:

score: -100
Wrong Answer
time: 625ms
memory: 6628kb

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:

48237 6151 70717 35679 73342 19561 28851 94252 13089 34865 69194 82763 50242 3745 97923 22597 24913 77581 53671 47428 4886 82224 61401 50007 93567 54152 28731 91278 6691 99937 26840 6048 46204 66044 20513 44469 45842 60735 27203 46818 18701 8020 72391 54368 50507 9261 86201 61758 35899 64763 18839 4...

result:

wrong answer Wrong Answer on Case#1