QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#758304 | #6443. Windblume Festival | surenjamts# | WA | 651ms | 3616kb | C++20 | 759b | 2024-11-17 17:36:22 | 2024-11-17 17:36:23 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define S second
#define F first
void solve(){
int n;
cin>>n;
int a[n];
int ans=0;
bool nem=0, has=0;
int sum=0;
for(int i=0; i<n; i++){
cin>>a[i];
if(a[i]>0) nem=1;
else has=1;
sum+=abs(a[i]);
}
if(n==1){
cout<<a[0]<<endl;
return;
}
if(nem and has){
cout<<sum<<endl;
}
else{
int mn=1e18;
for(int i=0; i<n; i++){
mn=(a[i]-a[(i+1)%n]);
ans=max(ans,sum-a[i]-a[(i+1)%n]-mn);
}
cout<<ans<<endl;
//cout<<sum-mn<<endl;
}
}
signed main(){
int t;
cin>>t;
while(t-- ) solve();
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
input:
5 4 1 -3 2 -4 11 91 66 73 71 32 83 72 79 84 33 93 12 91 66 73 71 32 83 72 79 84 33 33 93 13 91 66 73 71 32 83 72 79 84 33 33 33 93 1 0
output:
10 713 746 779 0
result:
ok 5 number(s): "10 713 746 779 0"
Test #2:
score: 0
Accepted
time: 443ms
memory: 3616kb
input:
1000000 1 2 1 -2 1 1 1 -1 1 2 1 1 1 2 1 -2 1 -2 1 2 1 1 1 1 1 2 1 2 1 2 1 -2 1 -2 1 0 1 2 1 1 1 -1 1 0 1 -2 1 0 1 1 1 1 1 -2 1 -2 1 2 1 1 1 2 1 1 1 1 1 0 1 2 1 0 1 -1 1 -1 1 -2 1 -2 1 0 1 -2 1 0 1 1 1 -1 1 2 1 0 1 -2 1 -2 1 0 1 1 1 -1 1 -2 1 -1 1 0 1 -1 1 -1 1 -1 1 -1 1 1 1 2 1 0 1 0 1 -2 1 2 1 2 1 ...
output:
2 -2 1 -1 2 1 2 -2 -2 2 1 1 2 2 2 -2 -2 0 2 1 -1 0 -2 0 1 1 -2 -2 2 1 2 1 1 0 2 0 -1 -1 -2 -2 0 -2 0 1 -1 2 0 -2 -2 0 1 -1 -2 -1 0 -1 -1 -1 -1 1 2 0 0 -2 2 2 -1 2 -2 -1 -2 -1 -2 2 -1 -1 0 -2 0 0 0 1 1 2 1 -1 0 -2 1 2 1 1 0 1 2 -2 -1 -1 0 -2 2 2 1 0 -1 0 -1 0 1 -2 2 1 -2 -2 0 -1 1 -1 2 -2 2 1 1 2 0 2...
result:
ok 1000000 numbers
Test #3:
score: 0
Accepted
time: 651ms
memory: 3592kb
input:
1000000 1 -182188011 1 -889401027 1 -379434063 1 -731536137 1 632523155 1 837208235 1 192807861 1 -162604370 1 963735146 1 736725265 1 -70315400 1 659481275 1 217883785 1 -396219883 1 653358757 1 -489133046 1 412498823 1 -210628961 1 -137310415 1 849916587 1 -50143945 1 -509463528 1 105005776 1 7382...
output:
-182188011 -889401027 -379434063 -731536137 632523155 837208235 192807861 -162604370 963735146 736725265 -70315400 659481275 217883785 -396219883 653358757 -489133046 412498823 -210628961 -137310415 849916587 -50143945 -509463528 105005776 738262345 352827098 391146170 108054338 601933024 -705538291...
result:
ok 1000000 numbers
Test #4:
score: -100
Wrong Answer
time: 352ms
memory: 3532kb
input:
666685 1 0 2 2 -1 1 2 1 2 1 -1 2 -2 2 1 0 2 -1 -2 2 2 -1 2 0 1 2 2 -1 1 1 2 1 1 1 1 2 0 2 2 1 0 2 0 2 2 -1 2 1 1 1 -1 1 -2 1 2 2 -1 0 2 -2 1 2 -2 -2 2 0 -1 1 -2 1 2 1 2 2 -1 -1 1 1 1 -2 1 2 2 -2 1 2 2 1 2 0 -2 1 -1 1 0 1 2 1 -2 2 2 0 1 -1 2 0 0 2 2 -2 2 -2 0 1 -2 1 1 2 2 0 1 -2 1 -1 2 1 -1 2 1 -2 2 ...
output:
0 3 2 2 -1 4 0 7 3 1 3 1 0 1 2 1 2 3 1 -1 -2 2 3 3 8 3 -2 2 2 4 1 -2 2 3 1 6 -1 0 2 -2 2 -1 0 4 6 -2 1 2 -2 -1 2 3 2 -2 3 4 2 6 -2 7 2 3 3 2 2 2 0 -2 6 1 1 0 2 -1 2 0 0 2 1 2 4 7 1 4 -2 -1 3 1 4 1 1 0 -2 2 1 2 2 1 2 -2 0 2 2 1 6 -1 0 -2 8 -1 6 4 3 1 0 -1 0 7 2 8 -1 1 -1 2 0 1 -1 -1 -2 7 0 2 1 -2 2 2...
result:
wrong answer 8th numbers differ - expected: '1', found: '7'