UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#189450#3308. 踹安狗heyuzhen100430ms2772kbC++113.2kb2023-10-04 11:25:282023-10-04 12:38:59

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,y,x;
bool ok;
struct node{
	ll x,p;
	bool operator < (const node t) const{
		return x < t.x;
	}
}a[100005];
int main(){
	cin >> n;
	for(ll i = 1;i <= n;i++){
		cin >> a[i].x;
		a[i].p = i;
	}sort(a + 1,a +  n + 1);	
	y = n;
	while(1){
		for(ll i = y;i >= 6;i--){
			if(a[i].x < a[i - 1].x + a[i - 3].x)
				if(a[i - 2].x < a[i - 4].x + a[i - 5].x){
					cout << a[i].p << " " << a[i - 1].p << " ";
					cout << a[i - 3].p << " " << a[i - 2].p << " ";
					cout << a[i - 4].p << " " << a[i - 5].p;
					return 0;
				}
			if(a[i].x < a[i - 1].x + a[i - 4].x)
				if(a[i - 2].x < a[i - 3].x + a[i - 5].x){
					cout << a[i].p << " " << a[i - 1].p << " ";
					cout << a[i - 4].p << " " << a[i - 2].p << " ";
					cout << a[i - 3].p << " " << a[i - 5].p;
					return 0;
				}
			if(a[i].x < a[i - 1].x + a[i - 5].x)
				if(a[i - 2].x < a[i - 3].x + a[i - 4].x){
					cout << a[i].p << " " << a[i - 1].p << " ";
					cout << a[i - 5].p << " " << a[i - 2].p << " ";
					cout << a[i - 3].p << " " << a[i - 4].p;
					return 0;
				}
			if(a[i].x < a[i - 2].x + a[i - 3].x)
				if(a[i - 1].x < a[i - 4].x + a[i - 5].x){
					cout << a[i].p << " " << a[i - 2].p << " ";
					cout << a[i - 3].p << " " << a[i - 1].p << " ";
					cout << a[i - 4].p << " " << a[i - 5].p;
					return 0;
				}
			if(a[i].x < a[i - 2].x + a[i - 4].x)
				if(a[i - 1].x < a[i - 3].x + a[i - 5].x){
					cout << a[i].p << " " << a[i - 2].p << " ";
					cout << a[i - 4].p << " " << a[i - 1].p << " ";
					cout << a[i - 3].p << " " << a[i - 5].p;
					return 0;
				}
			if(a[i].x < a[i - 2].x + a[i - 5].x)
				if(a[i - 1].x < a[i - 3].x + a[i - 4].x){
					cout << a[i].p << " " << a[i - 2].p << " ";
					cout << a[i - 5].p << " " << a[i - 1].p << " ";
					cout << a[i - 3].p << " " << a[i - 4].p;
					return 0;
				}
			if(a[i].x < a[i - 3].x + a[i - 4].x)
				if(a[i - 1].x < a[i - 2].x + a[i - 5].x){
					cout << a[i].p << " " << a[i - 3].p << " ";
					cout << a[i - 4].p << " " << a[i - 1].p << " ";
					cout << a[i - 2].p << " " << a[i - 5].p;
					return 0;
				}
			if(a[i].x < a[i - 3].x + a[i - 5].x)
				if(a[i - 1].x < a[i - 2].x + a[i - 4].x){
					cout << a[i].p << " " << a[i - 3].p << " ";
					cout << a[i - 5].p << " " << a[i - 1].p << " ";
					cout << a[i - 2].p << " " << a[i - 4].p;
					return 0;
				}
			if(a[i].x < a[i - 4].x + a[i - 5].x)
				if(a[i - 1].x < a[i - 2].x + a[i - 3].x){
					cout << a[i].p << " " << a[i - 4].p << " ";
					cout << a[i - 5].p << " " << a[i - 1].p << " ";
					cout << a[i - 2].p << " " << a[i - 3].p;
					return 0;
				}
			if(a[i].x < a[i - 1].x + a[i - 2].x)break;
		}if(y < 6 || (y == 6 && (a[y].x >= a[y - 1].x + a[y - 2].x))){
			cout << -1;
			return 0;
		}if(ok){
			y--;
			continue;
		}x = y - 3;
		for(ll i = y - 3;i >= 3;i--){
			x = i;
			if(a[i].x < a[i - 1].x + a[i - 2].x)break;
		}if(x < 3 || (x == 3 && (a[x].x >= a[x - 1].x + a[x - 2].x))){
			y--,ok = 1;
			continue;
		}cout << a[y].p << " " << a[y - 1].p << " ";
		cout << a[y - 2].p << " " << a[x].p << " ";
		cout << a[x - 1].p << " " << a[x - 2].p << " ";
//		cout <<" ok";
		return 0;
	}return 0;
}

详细

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

Test #1:

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

input:

6
687786726963580 676203373748984 426628665779852 783066834852223 788409887900962 36164560152862

output:

5 4 3 1 2 6

result:

ok ok

Test #2:

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

input:

20
665612175242670 838420208330677 801582841663181 573114053573948 570145522433228 906563303913564 9...

output:

15 14 6 10 16 2

result:

ok ok

Test #3:

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

input:

20
708734287831216 367988866435420 23858950707090 961945282338412 469845558417961 383310964188157 85...

output:

4 13 14 7 12 1

result:

ok ok

Test #4:

score: 10
Accepted
time: 56ms
memory: 2768kb

input:

100000
304796708724720 538498453876439 272022900179513 64771686604312 49795131913528 122642678650576...

output:

22622 54999 24031 75246 52777 33654

result:

ok ok

Test #5:

score: 10
Accepted
time: 64ms
memory: 2772kb

input:

100000
401463590116672 574794159983290 679510855924367 3515016398868 18629359633336 309138826949560 ...

output:

87809 76243 22922 45635 56292 81774

result:

ok ok

Test #6:

score: 10
Accepted
time: 61ms
memory: 2768kb

input:

100000
650414824324366 714620327617695 653497996245891 445204001954703 999391439747463 6263858934366...

output:

27505 22595 55644 59610 55277 16294

result:

ok ok

Test #7:

score: 10
Accepted
time: 60ms
memory: 2772kb

input:

100000
798607481723665 787327190767517 225653256415115 264493391035298 38757884845343 63308908452898...

output:

43704 2022 3286 24722 86099 31306

result:

ok ok

Test #8:

score: 10
Accepted
time: 64ms
memory: 2768kb

input:

100000
222887400037123 380435476311307 506633479487256 695689787367503 225141435774613 8716932685794...

output:

31077 34833 46310 78501 96772 88929

result:

ok ok

Test #9:

score: 10
Accepted
time: 61ms
memory: 2772kb

input:

100000
838952301577456 578873649923363 470539024130216 112846678383640 777480768771310 9418113986474...

output:

6175 58426 11997 151 72534 85075

result:

ok ok

Test #10:

score: 10
Accepted
time: 64ms
memory: 2768kb

input:

100000
1291082298539 329037669036270 339630396492775 140023099135725 423480310453938 842819131899076...

output:

96894 72680 55542 67349 35394 95072

result:

ok ok

Extra Test:

score: 0
Extra Test Passed