Language: C

#define N 12
double M[N][1<<N],r;
int D[N],n;
double dfs(int p,int f){
	if(M[p][f]<0){
		int i=0;
		M[p][f]=0;
		for(;i<n;i++){
			if(f&1<<i)continue;
			M[p][f]=max(M[p][f],dfs(i,f|1<<i)+D[p]+D[i]-2*sqrt(D[p]*D[i]));
		}
	}
	return M[p][f];
}
main(){
	int L,l,i,j,d;
	for(;~scanf("%d",&L);){
		d=0;do{scanf("%d",D+n);d+=D[n++]*2;}while(getchar()!='\n');
		for(i=0;i<n;i++)for(j=0;j<1<<n;j++)M[i][j]=-1;
		for(r=i=0;i<n;i++)r=max(r,dfs(i,1<<i));
		puts(d-r<=L?"OK":"NA");
	}
exit(0);
}

Compiler output:
main.c: In function 'dfs':
main.c:10:33: error: implicit declaration of function 'max' [-Wimplicit-function-declaration]
   10 |                         M[p][f]=max(M[p][f],dfs(i,f|1<<i)+D[p]+D[i]-2*sqrt(D[p]*D[i]));
      |                                 ^~~
main.c:10:71: error: implicit declaration of function 'sqrt' [-Wimplicit-function-declaration]
   10 |                         M[p][f]=max(M[p][f],dfs(i,f|1<<i)+D[p]+D[i]-2*sqrt(D[p]*D[i]));
      |                                                                       ^~~~
main.c:1:1: note: include '<math.h>' or provide a declaration of 'sqrt'
  +++ |+#include <math.h>
    1 | #define N 12
main.c:10:71: warning: incompatible implicit declaration of built-in function 'sqrt' [-Wbuiltin-declaration-mismatch]
   10 |                         M[p][f]=max(M[p][f],dfs(i,f|1<<i)+D[p]+D[i]-2*sqrt(D[p]*D[i]));
      |                                                                       ^~~~
main.c:10:71: note: include '<math.h>' or provide a declaration of 'sqrt'
main.c: At top level:
main.c:15:1: error: return type defaults to 'int' [-Wimplicit-int]
   15 | main(){
      | ^~~~
main.c: In function 'main':
main.c:17:15: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   17 |         for(;~scanf("%d",&L);){
      |               ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | #define N 12
main.c:17:15: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   17 |         for(;~scanf("%d",&L);){
      |               ^~~~~
main.c:17:15: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:18:59: error: implicit declaration of function 'getchar' [-Wimplicit-function-declaration]
   18 |                 d=0;do{scanf("%d",D+n);d+=D[n++]*2;}while(getchar()!='\n');
      |                                                           ^~~~~~~
main.c:18:59: note: 'getchar' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>'
main.c:21:17: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration]
   21 |                 puts(d-r<=L?"OK":"NA");
      |                 ^~~~
main.c:21:17: note: include '<stdio.h>' or provide a declaration of 'puts'
main.c:23:1: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration]
   23 | exit(0);
      | ^~~~
main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'exit'
  +++ |+#include <stdlib.h>
    1 | #define N 12
main.c:23:1: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
   23 | exit(0);
      | ^~~~
main.c:23:1: note: include '<stdlib.h>' or provide a declaration of 'exit'