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: 57ms
Memory: 1368kB
In contest: 1276

#include<stdio.h>
#include<algorithm>
using namespace std;
int main(void){
	int a[100001];
	int t;
	int i,j,k;
	scanf("%d",&t);
	for(i=1;i<=t;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+t);
	int max=a[t];
	int p=0;
	for(i=t;i>=1;i--){
		for(j=i-1;j>=1;j--){
			if(a[i]%a[j]!=0&&max<a[i]+a[j]){
				max=a[i]+a[j];
				p=1;
				break;
			}
			else if(max>=a[i]+a[j]){
				p=1;
				break;
			
			}
		
		}
		if(p==1)
			break;
	
	}
	printf("%d",max);
}