QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#602193#6443. Windblume Festivalbruteforce_WA 121ms3860kbC++20761b2024-09-30 20:52:542024-09-30 20:52:54

Judging History

你现在查看的是最新测评结果

  • [2024-09-30 20:52:54]
  • 评测
  • 测评结果:WA
  • 用时:121ms
  • 内存:3860kb
  • [2024-09-30 20:52:54]
  • 提交

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'