Summary
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 153 Accepted Submission(s): 105
[Technical Specification]
2 <= n <= 100
-1000000000 <= a i <= 1000000000
4 1 2 3 4 2 5 5
25 10
#include<iostream>
#include<cstdio>#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<cmath>
using namespace std;
typedef long long LL;
const int MAX=0xfffffff;
LL a[110];
vector<LL>b;
int main( )
{
//freopen("1.txt","r",stdin);
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=1;i<=n;i++)
scanf("%I64d",&a[i]);
b.clear();
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++)
{
LL t=a[i]+a[j];
b.push_back(t);
}
sort(b.begin(),b.end());
vector<LL>::iterator iter=unique(b.begin(),b.end());
b.erase(iter,b.end());
LL sum=0;
for(vector<LL>::iterator i=b.begin();i!=b.end();i++)
sum+=*i;
printf("%I64d\n",sum);
}
return 0;
}
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<cmath>
using namespace std;
typedef long long LL;
const int MAX=0xfffffff;
LL a[110];
LL b[5050];
int main( )
{
//freopen("1.txt","r",stdin);
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=1;i<=n;i++)
scanf("%I64d",&a[i]);
int cnt=-1;
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++)
b[++cnt]=a[i]+a[j];
sort(b,b+cnt+1);
LL sum=0;
for(int i=0;i<=cnt;i++)
{
if(i!=0&&b[i]==b[i-1])
continue;
else
sum+=b[i];
}
printf("%I64d\n",sum);
}
return 0;
}
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<cmath>
using namespace std;
typedef long long LL;
const int MAX=0xfffffff;
LL a[110];
LL b[5050];
int main( )
{
//freopen("1.txt","r",stdin);
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=1;i<=n;i++)
scanf("%I64d",&a[i]);
int cnt=-1;
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++)
b[++cnt]=a[i]+a[j];
sort(b,b+cnt+1);
LL t=unique(b,b+cnt+1)-b;
LL sum=0;
for(int i=0;i<t;i++)
{
sum+=b[i];
}
printf("%I64d\n",sum);
}
return 0;
}