ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#210163 | #3780. 选择翻转 | Yhlms | 100 | 513ms | 9064kb | C++11 | 526b | 2024-08-06 08:44:55 | 2024-08-06 12:01:33 |
answer
#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
#define int long long
//fixed << setprecision()
const int length = 1e6 + 5;
int n;
int a[length];
int ans = 0;
signed main()
{
ios::sync_with_stdio(false);
cin >> n;
for(int i = 1;i <= n;i++)
{
cin >> a[i];
}
ans = max(a[n] - a[1], a[1] - a[n]);
for(int i = 1;i <= n - 1;i++)
{
ans = max(ans, a[n] - a[i]);
}
for(int i = n;i >= 2;i--)
{
ans = max(ans, a[i] - a[1]);
}
cout << ans << endl;
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1264kb
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: 1260kb
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: 1260kb
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: 48ms
memory: 9060kb
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: 59ms
memory: 9056kb
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: 53ms
memory: 9060kb
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: 102ms
memory: 9064kb
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: 7504kb
input:
800000 498650216 784115938 534380004 928957839 962301970 194418961 126334785 792777182 745314326 876...
output:
501347498
result:
ok "501347498"
Test #9:
score: 10
Accepted
time: 99ms
memory: 9060kb
input:
1000000 343609688 60168770 513006292 112522542 710081534 997142492 166645644 24843096 205270658 1061...
output:
656389918
result:
ok "656389918"
Test #10:
score: 10
Accepted
time: 75ms
memory: 9060kb
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