UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#210244#3780. 选择翻转MarioWeng1001846ms9008kbC++11299b2024-08-06 09:45:522024-08-06 12:05:53

answer

#include<bits/stdc++.h>
using namespace std;
long long n,a[1000005],maxx,minn=1e18,w1,w2;
int main(){
	cin>>n;
	for(long long i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]>maxx)maxx=a[i];
		if(a[i]<minn)minn=a[i];
	}
	cout<<max(max(maxx-a[1],a[n]-minn),a[1]-a[n]);//考虑3种情况
	return 0;
}

详细

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

Test #1:

score: 10
Accepted
time: 1ms
memory: 1204kb

input:

1000
570728598 78380612 752009160 483622388 690675777 839701830 785601424 269638493 470443394 524296...

output:

571510733

result:

ok "571510733"

Test #2:

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

input:

1000
523121450 617641109 998599679 902664380 883696004 599125849 511039052 910900916 930157627 65125...

output:

476278378

result:

ok "476278378"

Test #3:

score: 10
Accepted
time: 1ms
memory: 1208kb

input:

1000
2940000 4740000 3750000 2580000 2640000 1620000 6840000 7260000 2580000 4860000 8940000 6270000...

output:

6060000

result:

ok "6060000"

Test #4:

score: 10
Accepted
time: 153ms
memory: 9008kb

input:

1000000
2 2 2 1 1 1 1 1 1 2 2 2 1 1 1 1 1 2 2 2 1 1 2 1 1 2 1 1 2 2 1 2 1 1 2 2 1 1 2 2 2 1 2 1 1 1 ...

output:

1

result:

ok "1"

Test #5:

score: 10
Accepted
time: 143ms
memory: 9004kb

input:

1000000
2 1 1 1 2 1 2 2 2 2 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 2 1 1 2 1 2 2 1 1 1 2 1 1 1 ...

output:

1

result:

ok "1"

Test #6:

score: 10
Accepted
time: 151ms
memory: 9008kb

input:

1000000
1 2 1 1 2 1 1 1 2 1 1 1 1 1 1 2 1 2 1 2 2 2 2 2 2 1 1 1 2 2 1 2 1 1 2 1 2 1 2 2 1 2 1 2 1 1 ...

output:

1

result:

ok "1"

Test #7:

score: 10
Accepted
time: 393ms
memory: 9008kb

input:

1000000
318646548 966361467 446289951 334795520 851916640 788241987 217528299 488090445 34266886 203...

output:

951879184

result:

ok "951879184"

Test #8:

score: 10
Accepted
time: 326ms
memory: 7444kb

input:

800000
498650216 784115938 534380004 928957839 962301970 194418961 126334785 792777182 745314326 876...

output:

501347498

result:

ok "501347498"

Test #9:

score: 10
Accepted
time: 373ms
memory: 9004kb

input:

1000000
343609688 60168770 513006292 112522542 710081534 997142492 166645644 24843096 205270658 1061...

output:

656389918

result:

ok "656389918"

Test #10:

score: 10
Accepted
time: 305ms
memory: 9008kb

input:

1000000
1000002 1000000 999999 999998 999997 999996 999995 999994 999993 999992 999991 999990 999989...

output:

1000000

result:

ok "1000000"

Extra Test:

score: 0
Extra Test Passed