ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#210152 | #3780. 选择翻转 | qiuqiu | 100 | 581ms | 9004kb | C++11 | 363b | 2024-08-06 08:38:49 | 2024-08-06 12:00:49 |
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#pragma GCC optimize(2)
int arr[1000005];
signed main(){
int n;
scanf("%lld",&n);
for(int i=1;i<=n;i++) scanf("%lld",arr+i);
int mx=INT_MIN;
mx=max(arr[n]-arr[1],arr[1]-arr[n]);
for(int i=2;i<n;i++) mx=max({mx,arr[n]-arr[i],arr[i]-arr[1]});
printf("%lld",mx);
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1196kb
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: 1196kb
input:
1000 523121450 617641109 998599679 902664380 883696004 599125849 511039052 910900916 930157627 65125...
output:
476278378
result:
ok "476278378"
Test #3:
score: 10
Accepted
time: 0ms
memory: 1196kb
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: 70ms
memory: 9000kb
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: 66ms
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: 68ms
memory: 9004kb
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: 107ms
memory: 9000kb
input:
1000000 318646548 966361467 446289951 334795520 851916640 788241987 217528299 488090445 34266886 203...
output:
951879184
result:
ok "951879184"
Test #8:
score: 10
Accepted
time: 77ms
memory: 7436kb
input:
800000 498650216 784115938 534380004 928957839 962301970 194418961 126334785 792777182 745314326 876...
output:
501347498
result:
ok "501347498"
Test #9:
score: 10
Accepted
time: 105ms
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: 88ms
memory: 9004kb
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