QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#247399#6443. Windblume FestivalDeterminant#Compile Error//C++14463b2023-11-11 14:17:042023-11-11 14:17:04

Judging History

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

  • [2023-11-11 14:17:04]
  • 评测
  • [2023-11-11 14:17:04]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;

void solve(){
    int n;cin>>n;if(n==1){cout<<a[0]<<endl;return;}
    vector<int> a(n);
    int s=0,mx=-2e9,mn=2e9;
    for(int i=0;i<n;i++){
        cin>>a[i];
        s+=abs(a[i]);
        mx=max(mx,a[i]);
        mn=min(mn,a[i]);
    }
    s-=abs(mx);
    s-=abs(mn);
    cout<<mx-mn+s<<endl;
}

signed main(){
    int t;cin>>t;
    while(t--)solve();
    return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:6:33: error: ‘a’ was not declared in this scope
    6 |     int n;cin>>n;if(n==1){cout<<a[0]<<endl;return;}
      |                                 ^