UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#214421#2386. 回忆Wonder_Fun80149ms5552kbC++794b2024-11-18 20:55:122024-11-19 08:33:40

answer

#include<bits/stdc++.h>
using namespace std;
void solve(){
	int n,t;
	cin>>n;
	t=(n*(n-1))/2;
	vector<int>a(t+1,0),b(n+1),ansArray;
	multiset<int>s,test;
	for(int i=1;i<=t;i++){
		cin>>a[i];
		s.insert(a[i]);
	}
	sort(a.begin()+1,a.end());
	for(int k=2;k<=t;k++){
		int mid=(a[2]+a[1]-a[k])/2;
		if(mid<=0)continue;
		test=s;
		b[1]=mid;
		int ans=1;
		multiset<int>::iterator it;
		for(int i=2;i<=n&&ans;i++){
			b[i]=*test.begin()-mid;
			test.erase(test.begin());
			for(int j=2;j<=i-1;j++){
				it=test.find(b[i]+b[j]);
				if(it!=test.end()){
					test.erase(it);
				}
				else{
					ans=0;
					break;
				}
			}
		}
		if(ans){
			ansArray=b;
			break;
		}
	}
	for(int i=1;i<=n;i++){
		cout<<ansArray[i]<<" ";
	}
}

int main()
{
	solve();
}

Details

小提示:点击横条可展开更详细的信息

Test #1:

score: 0
Runtime Error

input:

5
4 5 9 9 10 13 14 14 15 19

output:


result:


Test #2:

score: 10
Accepted
time: 0ms
memory: 1260kb

input:

5
5 9 9 10 12 12 13 16 17 17

output:

1 4 8 8 9 

result:

ok Your answer is correct.

Test #3:

score: 10
Accepted
time: 0ms
memory: 1260kb

input:

5
10 11 12 13 13 14 15 15 16 17

output:

4 6 7 8 9 

result:

ok Your answer is correct.

Test #4:

score: 10
Accepted
time: 0ms
memory: 1380kb

input:

50
9 13 15 20 20 20 21 22 22 26 26 26 27 27 27 28 29 31 31 32 32 33 33 33 33 33 34 34 34 35 35 36 37...

output:

1 8 12 14 19 19 20 21 25 25 26 31 33 34 35 37 38 40 43 44 47 48 50 52 52 52 54 54 54 55 55 57 61 68 ...

result:

ok Your answer is correct.

Test #5:

score: 10
Accepted
time: 0ms
memory: 1380kb

input:

50
9 11 14 14 16 16 16 18 19 19 21 21 21 21 22 22 23 23 23 23 24 25 25 26 26 26 26 26 26 26 27 27 27...

output:

2 7 9 12 12 14 14 16 20 20 21 23 24 24 24 25 28 29 30 35 35 38 38 38 41 42 44 44 47 51 55 55 56 57 5...

result:

ok Your answer is correct.

Test #6:

score: 0
Runtime Error

input:

50
7 9 12 16 19 21 26 27 29 29 31 33 33 33 34 35 36 36 36 36 37 38 38 38 38 39 39 40 40 40 41 41 42 ...

output:


result:


Test #7:

score: 10
Accepted
time: 34ms
memory: 5548kb

input:

300
660422 717145 1052261 1191442 1526558 1583281 1636913 1972029 2028752 2207583 2247577 2427928 25...

output:

162653 497769 554492 1028789 1474260 2044930 2084924 2265275 3785145 4260422 4369661 6246934 6467151...

result:

ok Your answer is correct.

Test #8:

score: 10
Accepted
time: 36ms
memory: 5552kb

input:

300
1719032 1728175 1968715 2265775 2506315 2515458 2534303 2752316 3002166 3035709 3071903 3081046 ...

output:

590716 1128316 1137459 1377999 1943587 2161600 2411450 2444993 2759692 2970632 3051238 3173758 37328...

result:

ok Your answer is correct.

Test #9:

score: 10
Accepted
time: 38ms
memory: 5548kb

input:

300
725653 809390 819383 974701 984694 1058923 1068431 1068916 1152653 1317964 1422171 1432164 15159...

output:

357830 367823 451560 616871 701093 1064341 1715237 2167391 2990472 3466200 3590383 4096481 4306285 4...

result:

ok Your answer is correct.

Test #10:

score: 10
Accepted
time: 41ms
memory: 5552kb

input:

300
2355315 3132486 3240117 3325566 3662015 3854305 3961936 4047385 4053636 4142315 4383834 4725290 ...

output:

816748 1538567 2315738 2423369 2508818 2845267 3236888 3325567 3908542 4527875 5625530 6283811 68958...

result:

ok Your answer is correct.