Why this code is not correct?

// Chef and easy problem | CodeChef
#include<bits/stdc++.h>
using namespace std;

int functioN(){
int n;
cin>>n;
if(n==1){
return 1;
}
vector v(n);
for(int i=0;i<n;i++){
scanf("%d",&v[i]);
}
sort(v.begin(),v.end());
int j=n-1,sum=0;
while(j>=0){
sum=sum+v[j];
j=j-2;
}
return sum;

}

int main(){
int t;
scanf("%d",&t);
while(t–){
cout<<functioN()<<endl;

return 0;
}
}

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

int functioN(){
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    int j=n-1,sum=0;
    while(j>=0){
        sum=sum+v[j];
        j=j-2;
    }
    return sum;
}

signed main(){
    int t;
    cin>>t;
    while(t--){
        cout<<functioN()<<endl;
    }
    return 0;
}

first dont’t use both cin and scanf,it will slow down your code,u can use cin.tie(NULL) and
ios_base::sync_with_stdio(false).

second a[i] can be upto 10**9,it will not fit in int.