QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#665356#6443. Windblume FestivalSYeaseWA 93ms3620kbC++171.4kb2024-10-22 11:40:102024-10-22 11:40:12

Judging History

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

  • [2024-10-22 11:40:12]
  • 评测
  • 测评结果:WA
  • 用时:93ms
  • 内存:3620kb
  • [2024-10-22 11:40:10]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<set>
#include<cmath>
#include<queue>
#define int long long
#define endl '\n'
#define F first
#define S second
#define sz size()
#define B begin()
#define D end()
#define pii pair<int,int>
#define IOS ios::sync_with_stdio(false)

using namespace std;
typedef long long ll;
const int N=1e6+10;
const int mod=1e9+7;

struct Nod{
	int b;
	int e;
}dian[N];
int a[N];

void solve()
{
	int n;
	cin>>n;
	int mn=1e9+10;
	
	int ans=0;
	int f=1;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]<0) f=0;
		mn=min(mn,a[i]);
		ans+=abs(a[i]);
	}
	if(n==0) cout<<ans<<endl;
	else{
		if(f)cout<<ans-2*mn<<endl;
		else cout<<ans<<endl;
	}
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	cin>>tc;
	while(tc--)
	{
		solve();
	}
	return 0;
}

int ksm(int m,int k,int mod)
{
	int ans=1;
	int t=m;
	while(k)
	{
		if(k&1) ans=ans*t%mod;
		t=t*t%mod;
		k>>=1;
	}
	return ans;
}

int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}

int exgcd(int a,int b,__int128& x,__int128& y)
{
	if(b==0){
		x=1,y=0;
		return a;//返回值为gcd(a,b)
	}
	int res=exgcd(b,a%b,x,y);//迭代到最底层
	int t=x;
	x=y;
	y=t-(a/b)*y;
	//完成实现时的x1=y2,y1=x2-(a/b)*y2
	//由于是从最深层实现的,故直接用公式向上层传递即可
	return res;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3620kb

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: 93ms
memory: 3596kb

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
...

result:

wrong answer 1st numbers differ - expected: '2', found: '-2'