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;
	string s;
	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:9: error: unknown type name 'string'
   17 |         string s;
      |         ^~~~~~
main.c:18:15: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   18 |         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:18:15: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   18 |         for(;~scanf("%d",&L);){
      |               ^~~~~
main.c:18:15: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:19:59: error: implicit declaration of function 'getchar' [-Wimplicit-function-declaration]
   19 |                 d=0;do{scanf("%d",D+n);d+=D[n++]*2;}while(getchar()!='\n');
      |                                                           ^~~~~~~
main.c:19:59: note: 'getchar' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>'
main.c:22:17: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration]
   22 |                 puts(d-r<=L?"OK":"NA");
      |                 ^~~~
main.c:22:17: note: include '<stdio.h>' or provide a declaration of 'puts'
main.c:24:1: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration]
   24 | 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:24:1: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
   24 | exit(0);
      | ^~~~
main.c:24:1: note: include '<stdlib.h>' or provide a declaration of 'exit'