QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#252725#6443. Windblume FestivallimpidWA 62ms3808kbC++141.3kb2023-11-16 08:51:392023-11-16 08:51:40

Judging History

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

  • [2023-11-16 08:51:40]
  • 评测
  • 测评结果:WA
  • 用时:62ms
  • 内存:3808kb
  • [2023-11-16 08:51:39]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<ctime>
#define int long long
#define pii pair<int,int>
#define pb push_back
#define LL long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
inline int read(){
    int f=1,ans=0; char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
    return f*ans;
}
const int MAXN=1e6+11;
int N,Sum,A[MAXN],cas; bool f1=0,f2=0;
signed main(){
    //freopen("1.in","r",stdin);
    cas=read(); while(cas--){
        f1=0,f2=1;
        N=read(); for(int i=1;i<=N;i++){
            A[i]=read(); 
            f2&=(A[i]<0);
            f1|=(A[i]<0);
        }
        //cerr<<f1<<" "<<f2<<endl;
        if(f1&f2){
            sort(A+1,A+N+1); Sum=0;
            for(int i=1;i<N;i++) Sum+=-A[i];
            printf("%lld\n",Sum+A[N]);
            continue;
        }
        if(f1){
            Sum=0; for(int i=1;i<=N;i++) Sum+=abs(A[i]);
            printf("%lld\n",Sum);
            continue;
        }
        Sum=0;
        sort(A+1,A+N+1); for(int i=1;i<=N;i++) Sum+=A[i];
        printf("%lld\n",Sum-2*A[1]);
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 62ms
memory: 3808kb

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'