Start: Jun, 28, 2019 08:42:00
2019杭州师范大学第一届程序设计竞赛新生赛
End: Jun, 28, 2019 11:42:00
Time elapsed:
Time remaining:

Problem_ID: H
Result: Accepted
Time: 69ms
Memory: 1756kB
In contest: 1276

#include<stdio.h>
#include<stdlib.h>
int comp(const void *p,const void *q){
	return (*(int *)p-*(int *)q);
}
int main()
{
	int n;
	int a[100000];
	scanf("%d",&n);
	int i,j,sum;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	qsort(a,n,sizeof(int),comp);
	sum=a[n-1];
	
	for(i=n-1;i>n/3;i--){
		for(j=n-1;j>n/3;j--){
			if(a[i]+a[j]<=sum){
				break;
			}
			if(a[i]%a[j]!=0&&a[j]%a[i]!=0){
				sum=a[i]+a[j];
			}
		}
	}
	printf("%d",sum);
	return 0;
}