QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#184795#6443. Windblume FestivalKAZE_mae#WA 475ms3672kbC++171.4kb2023-09-21 12:46:182023-09-21 12:46:18

Judging History

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

  • [2023-09-21 12:46:18]
  • 评测
  • 测评结果:WA
  • 用时:475ms
  • 内存:3672kb
  • [2023-09-21 12:46:18]
  • 提交

answer

#include<bits/stdc++.h>

#define int long long
#define endl '\n'
#define mod 998244353
#define ffor(n) for(int i = 0;i < n;++i)


const int N = 2000006; 

using namespace std;

void build_log();
int mv_x[4] = {1,0,-1,0};
int mv_y[4] = {0,1,0,-1};
int year[2][15] = {{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};//1是闰年,0是非闰年
int t;
int m_log2[500005]; // log2(x) + 1
int k;
int n,m;
int h;



vector<int>v;


signed main()
{
    //ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a;
        int sum = 0;
        int mmin = 10000000000;
        int mmax = -10000000000;
        ffor(n)
        {
            cin>>a;
            if(a < 0)
            {
                sum -= a;
            }
            else
            {
                sum += a;
            }
            mmin = min(mmin,a);
            mmax = max(mmax,a);
        }
        if(mmin > 0)
        {
            sum -= 2 * mmin;
        }
        if(mmax < 0)
        {
            sum += mmax*2;
        }
        cout<<sum<<endl;
    }




    



    return 0;
}





void build_log()
{
    for(int i = 1;i <= n;i++)
    {
        m_log2[i] = m_log2[i-1] + ((1 << m_log2[i-1]) == i);
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 475ms
memory: 3592kb

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

result:

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