QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#602193 | #6443. Windblume Festival | bruteforce_ | WA | 121ms | 3860kb | C++20 | 761b | 2024-09-30 20:52:54 | 2024-09-30 20:52:54 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+7,inf=1e18,mod=998244353;
int check(int x,int y)
{
if(x<0&&y<0)
{
x=-x;
y=-y;
}
return max(0ll,min(x,y));
}
void O_o()
{
int n;
cin>>n;
vector<int> a(n+1);
a[0]=inf;
int ans=0,id=0,bz=0;
for(int i=1; i<=n; i++)
{
cin>>a[i];
ans+=abs(a[i]);
}
if(n==1)
{
cout<<ans<<"\n";
return;
}
for(int i=1; i<=n; i++)
a.push_back(a[i]);
int mi=inf;
for(int i=1; i<=n; i++)
{
mi=min(mi,check(a[i],a[i+1]));
}
cout<<ans-mi*2<<"\n";
}
signed main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cout<<fixed<<setprecision(12);
int T=1;
cin>>T;
while(T--)
{
O_o();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3860kb
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: -100
Wrong Answer
time: 121ms
memory: 3664kb
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 2 2 1 0 1 0 1 2 2 1 2 1 1 0 1 1 1 0 2 2 1 0 2 0 ...
result:
wrong answer 2nd numbers differ - expected: '-2', found: '2'