QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#268908#7750. Revenge on My Bossucup-team134#WA 30ms5832kbC++141.5kb2023-11-29 00:12:442023-11-29 00:12:45

Judging History

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

  • [2023-11-29 00:12:45]
  • 评测
  • 测评结果:WA
  • 用时:30ms
  • 内存:5832kb
  • [2023-11-29 00:12:44]
  • 提交

answer

#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#define pb push_back
#define ll long long

const int N=100050;
int a[N],b[N],c[N],d[N];

/*int Get(int i){
	if(a[i]<b[i])return 0;
	if(a[i]==b[i])return 1;
	return 2;
}
bool cmp(int i,int j){
	if(Get(i)!=Get(j))return Get(i)<Get(j);
	if(Get(i)==0){
		if(c[i]!=c[j])return c[i]<c[j];
		return b[i]-a[i]>b[j]-a[j];
	}else if(Get(i)==1){
		return false;
	}else{
		if(c[i]!=c[j])return c[i]>c[j];
		return a[i]-b[i]<a[j]-b[j];
	}
}*/
ll add;
bool cmp2(int i,int j){
	//if(c[i]!=c[j])return c[i]<c[j];
	//return d[i]>d[j];
	return (ll)(d[j]+add)*c[i]<(ll)(d[i]+add)*c[j];
}
int main(){
	int t;
	scanf("%i",&t);
	while(t--){
		int n;
		scanf("%i",&n);
		vector<int> ans,L,R;
		for(int i=1;i<=n;i++){
			scanf("%i %i %i",&a[i],&b[i],&c[i]);
			d[i]=abs(a[i]-b[i]);
			if(a[i]<b[i])L.pb(i);
			if(a[i]>b[i])R.pb(i);
		}
		add=0;
		for(int i=1;i<=n;i++){
			if(a[i]>b[i])add+=b[i];
		}
		sort(L.begin(),L.end(),cmp2);
		add=0;
		for(int i=1;i<=n;i++){
			if(a[i]<b[i])add+=a[i];
		}
		sort(R.rbegin(),R.rend(),cmp2);
		for(int i:L)ans.pb(i);
		for(int i=1;i<=n;i++){
			if(d[i]==0)ans.pb(i);
		}
		for(int i:R)ans.pb(i);
		for(int i:ans)printf("%i ",i);
		printf("\n");
		/*printf(" ");
		for(int i=1;i<n;i++){
			if(!cmp2(ans[i-1],ans[i])){
				printf("=");
			}else{
				printf("<");
			}
			printf(" ");
		}
		printf("\n");*/
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 30ms
memory: 5832kb

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:

77582 77581 82112 72163 18220 43645 30468 80107 54173 17444 14872 8630 50133 26305 35 70096 40298 10072 56385 75312 79444 19284 81622 95793 96892 82320 8443 11434 56765 72103 89089 86041 48305 32033 88191 83243 9383 66880 81866 31386 23642 79775 66240 99937 38682 18931 39524 48449 36540 202 11001 62...

result:

wrong answer Wrong Answer on Case#1