Problem:
パティシエ
ケーキ屋さんが、まちまちな大きさのロールケーキをたくさん作りました。あなたは、このケーキを箱に並べる仕事を任されました。
ロールケーキはとてもやわらかいので、他のロールケーキが上に乗るとつぶれてしまいます。ですから、図(a) のように全てのロールケーキは必ず箱の底面に接しているように並べなければなりません。並べ替えると必要な幅も変わります。
図(a)
図(b)
n
個のロールケーキの半径
r
1
,
r
2
, ...,
r
n
と箱の長さを読み込み、それぞれについて、箱の中にうまく収まるかどうか判定し、並べる順番を工夫すると箱に入る場合は "OK"、どう並べても入らない場合には "NA"を出力するプログラムを作成してください。
ロールケーキの断面は円であり、箱の壁の高さは十分に高いものとします。 ただし、ロールケーキの半径は 3 以上 10 以下の整数とします。つまり、ケーキの半径に極端な差はなく、図(b) のように大きなケーキの間に小さなケーキがはまり込んでしまうことはありません。
Input
入力は複数のデータセットからなります。各データセットは以下の形式で与えられます。
W
r
1
r
2
...
r
n
最初に箱の長さを表す整数
W
(1 ≤
W
≤ 1,000) が与えられます。 続いて、空白区切りで各ロールケーキの半径を表す整数
r
i
(3 ≤
r
i
≤ 10) が与えられます。ケーキの個数
n
は 12 以下です。
データセットの数は 50 を超えません。
Output
データセットごとに OK または NA を１行に出力してください。
Sample Input
30 4 5 6
30 5 5 5
50 3 3 3 10 10
49 3 3 3 10 10
Output for the Sample Input
OK
OK
OK
NA

Submitted solutions:

code_snippet: #include <bits/stdc++.h>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

// template<typename T> T inf;
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

ld dp[1 << 12][16];

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha;
  cout.imbue(loc);
  string line;
  while (getline(cin, line)) {
    istringstream is(line);
    int W, in;
    is >> W;
    vector<int> r;
    while (is >> in) r.push_back(in);
    const int n = r.size();
    REP(bit,1<<n) REP(i,n) dp[bit][i] = 1e18;
    REP(i,n) dp[1 << i][i] = r[i];
    REP(bit,1<<n) REP(i,n) REP(j,n) {
      if (!((bit >> i) & 1)) continue;
      if ((bit >> j) & 1) continue;
      const ld d = sqrt((r[i] + r[j]) * (r[i] + r[j]) - (r[i] - r[j]) * (r[i] - r[j]));
      chmin(dp[bit | (1 << j)][j], dp[bit][i] + d);
    }
    ld min_w = 1e18;
    REP(i,n) chmin(min_w, dp[(1 << n) - 1][i] + r[i]);
    if (min_w < W + 1e-9) cout << "OK" << endl;
    else cout << "NA" << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 4376
final_rank: 17

code_snippet: #include<bits/stdc++.h>
using namespace std;
double memo[15][15][10000];
double INF = 10001000;
vector<double> vec;
double dp(int id, int bef, int bit){
    if(id == vec.size()) return 0;
    if(memo[id][bef][bit]!=INF) return memo[id][bef][bit];
    double res = INF;
    for(int i=0;i<vec.size();i++){
        if((bit&1<<i) == 0){
            if(id == 0) res = min(res, dp(id+1, i, (1<<i))+vec[i]*2);
            else{
                double dist = sqrt(pow(vec[i]+vec[bef], 2)-pow(vec[i]-vec[bef], 2));
                res = min(res, dp(id+1, i, (bit|1<<i))+dist+vec[i]-vec[bef]);
            }
        }
    }
    return memo[id][bef][bit] = res;
}
int main(){
    string str;
    double w, r;
    while(getline(cin, str)){
        stringstream ss(str);
        ss >> w;
        while(ss >> r) vec.push_back(r);
        fill_n(**memo, 15*15*10000, INF);
        if(w >= dp(0, 0, 0)) cout << "OK" << endl;
        else cout << "NA" << endl;
        vec.clear();
    }
    return(0);
}
accuracy: 1
time_ms: 80
memory_kb: 20796
final_rank: 20

code_snippet: #line 1 "library/my_template.hpp"
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using u32 = unsigned int;
using u64 = unsigned long long;
using i128 = __int128;

template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vc<T>>;
template <class T>
using vvvc = vector<vvc<T>>;
template <class T>
using vvvvc = vector<vvvc<T>>;
template <class T>
using vvvvvc = vector<vvvvc<T>>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;

#define vec(type, name, ...) vector<type> name(__VA_ARGS__)
#define vv(type, name, h, ...) \
  vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...)   \
  vector<vector<vector<type>>> name( \
      h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...)       \
  vector<vector<vector<vector<type>>>> name( \
      a, vector<vector<vector<type>>>(       \
             b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))

// https://trap.jp/post/1224/
#define FOR1(a) for (ll _ = 0; _ < ll(a); ++_)
#define FOR2(i, a) for (ll i = 0; i < ll(a); ++i)
#define FOR3(i, a, b) for (ll i = a; i < ll(b); ++i)
#define FOR4(i, a, b, c) for (ll i = a; i < ll(b); i += (c))
#define FOR1_R(a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR2_R(i, a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR3_R(i, a, b) for (ll i = (b)-1; i >= ll(a); --i)
#define FOR4_R(i, a, b, c) for (ll i = (b)-1; i >= ll(a); i -= (c))
#define overload4(a, b, c, d, e, ...) e
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FOR_R(...) \
  overload4(__VA_ARGS__, FOR4_R, FOR3_R, FOR2_R, FOR1_R)(__VA_ARGS__)

#define FOR_subset(t, s) for (ll t = s; t >= 0; t = (t == 0 ? -1 : (t - 1) & s))
#define all(x) x.begin(), x.end()
#define len(x) ll(x.size())
#define elif else if

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second

#define stoi stoll

template <typename T, typename U>
T SUM(const vector<U> &A) {
  T sum = 0;
  for (auto &&a: A) sum += a;
  return sum;
}

#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define LB(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define UB(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end())

int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(u32 x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int popcnt(u64 x) { return __builtin_popcountll(x); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2)
int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(u32 x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2)
int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(u32 x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }

template <typename T>
T pick(deque<T> &que) {
  T a = que.front();
  que.pop_front();
  return a;
}

template <typename T>
T pick(pq<T> &que) {
  T a = que.top();
  que.pop();
  return a;
}

template <typename T>
T pick(pqg<T> &que) {
  assert(que.size());
  T a = que.top();
  que.pop();
  return a;
}

template <typename T>
T pick(vc<T> &que) {
  assert(que.size());
  T a = que.back();
  que.pop_back();
  return a;
}

template <typename T, typename U>
T ceil(T x, U y) {
  return (x > 0 ? (x + y - 1) / y : x / y);
}

template <typename T, typename U>
T floor(T x, U y) {
  return (x > 0 ? x / y : (x - y + 1) / y);
}

template <typename T, typename U>
pair<T, T> divmod(T x, U y) {
  T q = floor(x, y);
  return {q, x - q * y};
}

template <typename F>
ll binary_search(F check, ll ok, ll ng) {
  assert(check(ok));
  while (abs(ok - ng) > 1) {
    auto x = (ng + ok) / 2;
    tie(ok, ng) = (check(x) ? mp(x, ng) : mp(ok, x));
  }
  return ok;
}

template <typename F>
double binary_search_real(F check, double ok, double ng, int iter = 100) {
  FOR(iter) {
    double x = (ok + ng) / 2;
    tie(ok, ng) = (check(x) ? mp(x, ng) : mp(ok, x));
  }
  return (ok + ng) / 2;
}

template <class T, class S>
inline bool chmax(T &a, const S &b) {
  return (a < b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
  return (a > b ? a = b, 1 : 0);
}

vc<int> s_to_vi(const string &S, char first_char) {
  vc<int> A(S.size());
  FOR(i, S.size()) { A[i] = S[i] - first_char; }
  return A;
}

template <typename T, typename U>
vector<T> cumsum(vector<U> &A, int off = 1) {
  int N = A.size();
  vector<T> B(N + 1);
  FOR(i, N) { B[i + 1] = B[i] + A[i]; }
  if (off == 0) B.erase(B.begin());
  return B;
}

template <typename CNT, typename T>
vc<CNT> bincount(const vc<T> &A, int size) {
  vc<CNT> C(size);
  for (auto &&x: A) { ++C[x]; }
  return C;
}

// stable
template <typename T>
vector<int> argsort(const vector<T> &A) {
  vector<int> ids(A.size());
  iota(all(ids), 0);
  sort(all(ids),
       [&](int i, int j) { return A[i] < A[j] || (A[i] == A[j] && i < j); });
  return ids;
}

// A[I[0]], A[I[1]], ...
template <typename T>
vc<T> rearrange(const vc<T> &A, const vc<int> &I) {
  int n = len(I);
  vc<T> B(n);
  FOR(i, n) B[i] = A[I[i]];
  return B;
}
#line 1 "library/other/io2.hpp"
#define INT(...) \
  int __VA_ARGS__; \
  IN(__VA_ARGS__)
#define LL(...) \
  ll __VA_ARGS__; \
  IN(__VA_ARGS__)
#define STR(...) \
  string __VA_ARGS__; \
  IN(__VA_ARGS__)
#define CHR(...) \
  char __VA_ARGS__; \
  IN(__VA_ARGS__)
#define DBL(...) \
  long double __VA_ARGS__; \
  IN(__VA_ARGS__)

#define VEC(type, name, size) \
  vector<type> name(size);    \
  read(name)
#define VV(type, name, h, w)                     \
  vector<vector<type>> name(h, vector<type>(w)); \
  read(name)

void read(int &a) { cin >> a; }
void read(long long &a) { cin >> a; }
void read(char &a) { cin >> a; }
void read(double &a) { cin >> a; }
void read(long double &a) { cin >> a; }
void read(string &a) { cin >> a; }
template <class T, class S> void read(pair<T, S> &p) { read(p.first), read(p.second); }
template <class T> void read(vector<T> &a) {for(auto &i : a) read(i);}
template <class T> void read(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &...tail) {
  read(head);
  IN(tail...);
}

template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& A) {
  os << A.fi << " " << A.se;
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& A) {
  for (size_t i = 0; i < A.size(); i++) {
    if(i) os << " ";
    os << A[i];
  }
  return os;
}

void print() {
  cout << "\n";
  cout.flush();
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(Tail)) cout << " ";
  print(forward<Tail>(tail)...);
}

void YES(bool t = 1) { print(t ? "YES" : "NO"); }
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1) { print(t ? "Yes" : "No"); }
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1) { print(t ? "yes" : "no"); }
void no(bool t = 1) { yes(!t); }
#line 1 "library/string/split.hpp"
vc<string> split(string S, char sep = ',') {
  vc<string> res = {""};
  for (auto&& s: S) {
    if (s == sep)
      res.eb("");
    else
      res.back() += s;
  }
  return res;
}

vc<string> split(string S, string seps = " ,") {
  vc<string> res = {""};
  for (auto&& s: S) {
    if (count(all(seps), s))
      res.eb("");
    else
      res.back() += s;
  }
  return res;
}
#line 4 "main.cpp"

void solve() {
  string line;
  while (getline(cin, line)) {
    auto tokens = split(line, " ");
    ll W = stoi(tokens[0]);
    vi A;
    FOR(i, 1, len(tokens)) { A.eb(stoi(tokens[i])); }
    using Re = double;
    const ll INF = 1LL << 60;
    ll N = len(A);
    vv(Re, dp, 1 << N, N, INF);
    FOR(i, N) dp[1 << i][i] = A[i];
    FOR(s, 1 << N) FOR(i, N) {
      FOR(j, N) {
        int t = s | 1 << j;
        if (s == t) continue;
        Re a = 2 * sqrt(A[i] * A[j]);
        chmin(dp[t][j], dp[s][i] + a);
      }
    }
    bool ok = 0;
    FOR(i, N) {
      if (dp[(1 << N) - 1][i] + A[i] <= W) ok = 1;
    }
    print(ok ? "OK" : "NA");
  }
}

signed main() {
  solve();

  return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 3588
final_rank: 18

code_snippet: #include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000


int main(){
	
	int w;
	while(cin>>w){
		cin.ignore();
		vector<int> r;
		string s;
		getline(cin, s);
        stringstream ss(s);
        while(!ss.eof()){
			int t;
            ss >> t;
            r.push_back(t);
        }
		
		int n = r.size();
		vector dp(1<<n,vector<double>(n,1e9));
		rep(i,n){
			dp[1<<i][i] = r[i];
		}
		
		rep(i,1<<n){
			if(i==0)continue;
			rep(j,n){
				if(dp[i][j]==1e9)continue;
				rep(k,n){
					if((i>>k)&1)continue;
					dp[i|(1<<k)][k] = min(dp[i|(1<<k)][k], dp[i][j] + sqrt(pow(r[j]+r[k],2.0) - pow(abs(r[j]-r[k]),2.0)));
				}
			}
		}
		double ans = 1e9;
		
		rep(j,n){
			ans = min(ans,dp.back()[j] + r[j]);
		}

		//cout<<ans<<endl;
		if(ans < w+1e-10)cout<<"OK"<<endl;
		else cout<<"NA"<<endl;
		
	}
		
	
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3604
final_rank: 7

code_snippet: #include<bits/stdc++.h>
using namespace std;

int main(){
  for(;;){
    vector<string> v;
    string str,s;
    getline(cin,str);
    stringstream ss{str};
    while(getline(ss,s,' ')) v.push_back(s);
    if(str == "") break;
    int w = stoi(v[0]);
    long double W = w;
    int N = v.size()-1;
    vector<int> r(N);
    for(int i=0;i<N;i++) r[i] = stoi(v[i+1]);
    vector<long double> R(N);
    for(int i=0;i<N;i++) R[i] = r[i];
    vector<vector<long double>> dp((1<<N),vector<long double>(N,1000000000));
    for(int i=0;i<N;i++) dp[(1<<i)][i] = R[i];
    for(int i=1;i<(1<<N);i++){
      for(int j=0;j<N;j++){
        if(i & (1<<j)){
          for(int k=0;k<N;k++){
            if(!(i & (1<<k))){
              long double val = dp[i][j]+sqrt((R[j]+R[k])*(R[j]+R[k])-(R[j]-R[k])*(R[j]-R[k]));
              if(i+(1<<k) == (1<<N)-1) val += R[k];
              dp[i+(1<<k)][k] = min(dp[i+(1<<k)][k],val);
            }
          }
        }
      }
    }
    long double Min = 1000000000;
    for(int i=0;i<N;i++) Min = min(Min,dp[(1<<N)-1][i]);
    if(Min <= W) cout << "OK" << endl;
    else cout << "NA" << endl;
  }
}
accuracy: 1
time_ms: 20
memory_kb: 3900
final_rank: 13

code_snippet: #include<bits/stdc++.h>
using namespace std;

int main(){
    string s;
    while(getline(cin, s)){
        vector<int> a;
        a.push_back(0);
        for(int i = 0; i < s.size(); i++){
            if(s[i] == ' '){
                a.push_back(0);
            }else{
                a.back() *= 10;
                a.back() += s[i] - '0';
            }
        }
        int W = a[0];
        a.erase(a.begin());
        int n = a.size();
        vector<vector<double>> dp(1 << n, vector<double>(n, 1 << 30));
        for(int i = 0; i < n; i++)dp[1 << i][i] = a[i];
        for(int i = 0; i < (1 << n); i++){
            for(int j = 0; j < n; j++){
                if(~i >> j & 1)continue;
                for(int k = 0; k < n; k++){
                    if(i >> k & 1)continue;
                    dp[i | (1 << k)][k] = min(dp[i | (1 << k)][k], dp[i][j] + 2 * sqrt(a[j] * a[k]));
                }
            }
        }
        double ans = 1 << 30;
        for(int i = 0; i < n; i++)ans = min(ans, dp.back()[i] + a[i]);
        cout << (ans <= W ? "OK" : "NA") << '\n';
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3432
final_rank: 4

code_snippet: #define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<list>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<iomanip>
#include<cctype>
#include<sstream>
#include<regex>
#include<bitset>
#include<random>
using namespace std;
#define int long long
#define uint unsigned long long
const int mod=1e9+7;
const int Mod=998244353;
const int inf=mod*mod;
const double eps=1e-9;
double dp[4096][12];
signed main(){
	int w;
	while(cin>>w){
		string s;
		getline(cin,s);
		stringstream ss(s);
		int num;
		vector<int>r;
		while(ss>>num)
			r.push_back(num);
		int n=r.size();
		bool ok=0;
		for(int s=0;s<1<<n;s++){
			for(int i=0;i<n;i++){
				if(~s>>i&1)
					continue;
				dp[s][i]=inf;
				int ps=s&~(1<<i);
				if(ps==0)
					dp[s][i]=r[i];
				for(int j=0;j<n;j++)
					if(ps>>j&1)
						dp[s][i]=min(dp[s][i],dp[ps][j]+2*sqrt(r[i]*r[j]));
				if(s==(1<<n)-1){
					dp[s][i]+=r[i];
					if(dp[s][i]<=w)
						ok=1;
				}
			}
		}
		cout<<(ok?"OK":"NA")<<endl;
	}
}
accuracy: 1
time_ms: 10
memory_kb: 3744
final_rank: 9

code_snippet: #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    string s;
    while(getline(cin, s)){
        vector<int> v{0};
        for (auto &&i : s) {
            if(i == ' ') v.emplace_back(0);
            else v.back() = v.back()*10+i-'0';
        }
        int W = v.front();
        int n = v.size()-1;
        vector<int> A(v.begin()+1,v.end());
        auto dp = make_v(n, 1 << n, 1e12);
        for (int i = 0; i < n; ++i) {
            dp[i][1 << i] = A[i];
        }
        for (int j = 0; j < (1 << n); ++j) {
            for (int i = 0; i < n; ++i) {
                for (int k = 0; k < n; ++k) {
                    if(!(j & (1 << k))){
                        chmin(dp[k][j^(1 << k)], dp[i][j]+2*sqrt(A[i]*A[k]));
                    }
                }
            }
        }
        int ok = 0;
        for (int i = 0; i < n; ++i) {
            if(dp[i].back()+A[i] <= W+1e-10) ok = 1;
        }
        puts(ok ? "OK" : "NA");
    }
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3384
final_rank: 11

code_snippet: #include <bits/stdc++.h>

using namespace std;

double RofCake[12];
double Dp[4096][12];

const double INF = DBL_MAX;

unsigned popcnt(unsigned u)
{
	unsigned ret = 0;
	while (u)
	{
		u = (u & (u - 1));
		ret++;
	}
	return ret;
}

double getDistance(double r1, double r2)
{
	return sqrt(pow(r1 + r2, 2) - pow(r1 - r2, 2));
}

double solve(int index) {
	int next;
	double ans;

	for (int i = 0; i < (1<<index); i++) {
		for (int j = 0; j < index; j++) {
			for (int k = 0; k < index; k++) {
				next = i | (1 << j);
				if (i == 0) {
					Dp[next][j] = min( Dp[next][j], RofCake[j]);
					continue;
				}
				if (Dp[i][k] == INF) {
					continue;
				}

				if (popcnt(next) == index) {
					Dp[next][j] = min(Dp[next][j], Dp[i][k] + getDistance(RofCake[k], RofCake[j]) + RofCake[j]);
				}
				else {
					Dp[next][j] = min(Dp[next][j], Dp[i][k]+getDistance(RofCake[k],RofCake[j]));
				}
			}
		}
	}

	ans = INF;
	for (int i = 0; i < index; i++) {
		ans = min(ans, Dp[(1 << index) - 1][i]);
	}

	return ans;
}


int main() {
	int w, index;
	string str;
	stringstream ss;
	double ans;

	while (getline(cin,str)) {
		ss << str;
		ss >> w;
		index = 0;
		memset(RofCake, 0, sizeof(RofCake));
		while (ss >> RofCake[index]) {
			//cout<<RofCake[index]<<ends;
			index++;
		}
		//cout << index << endl;
		for (int i = 0; i < (1 << index); i++) {
			for (int j = 0; j < index; j++) {
				Dp[i][j] = INF;
			}
		}

		ans = solve(index);

		if (ans > w) {
			cout << "NA" << endl;
		}
		else {
			cout << "OK" << endl;
		}

		str = "";
		ss.clear();
	}
	

	return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 3608
final_rank: 19

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int string2int(string s) {
    return atoi(s.c_str());
}

vector<int> parseInputs(string &s) {
    vector<int> res;
    s += " ";
    int lst = 0;
    REP(i, 0, s.size()) {
        if (s[i] == ' ') {
            res.push_back(string2int(s.substr(lst, i - lst)));
            lst = i + 1;
        }
    }
    return res;
}

#include <cmath>
double calcDist(double r1, double r2) {
    return sqrt(r1 * r1 - r2 * r2);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    while (true) {
        getline(cin, s);
        if (s.size() == 0) break;
        auto res = parseInputs(s);
        int W = res[0];
        res.erase(res.begin());
        int n = res.size();
        auto dp = make_v(1 << n, n, 1e+15);
        REP(i, 0, n) {
            dp[1 << i][i] = res[i];
        }
        REP(i, 1, 1 << n) {
            REP(j, 0, n) {
                if (!((i >> j) & 1)) continue;
                REP(k, 0, n) {
                    if ((i >> k) & 1) continue;
                    double dist = calcDist(res[j] + res[k], abs(res[j] - res[k]));
                    int nxt = i | (1 << k);
                    dp[nxt][k] = min(dp[nxt][k], dp[i][j] + dist);
                }
            }
        }
        double ans = 1e+15;
        REP(i, 0, n) {
            ans = min(ans, dp[(1 << n) - 1][i] + res[i]);
        }
        ans -= 1e-6;
        cout << (ans <= W ? "OK" : "NA") << endl;
    }

    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3292
final_rank: 1

code_snippet: #include <bits/stdc++.h>

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;

// strをdelimiterで分割する
vector<string> split(const string &str, const string &delimiter) {
    vector<string> res;
    size_t current = 0, found, delimlen = delimiter.size();
    while ((found = str.find(delimiter, current)) != string::npos) {
        res.emplace_back(string(str, current, found - current));
        current = found + delimlen;
    }
    res.emplace_back(string(str, current, str.size() - current));
    return res;
}

int main() {
    cin.tie(0);
	ios::sync_with_stdio(false);

	string s;
	while (getline(cin, s)) {
	    vector<string> raw = split(s, " ");
	    int W;
	    vector<int> v;
	    W = stoi(raw[0]);
	    FOR(i, 1, raw.size()) {
	        v.emplace_back(stoi(raw[i]));
	    }
	    int n = v.size();

	    vector<vector<double>> dp(1 << n, vector<double>(n, INF));
	    FOR(i, 0, n) {
	        dp[1 << i][i] = v[i];
	    }

	    FOR(b, 0, 1 << n) {
	        FOR(i, 0, n) {
//                assert(dp[b][i] != INF);

                FOR(j, 0, n) {
                    if ((b & (1 << j)) == 0) {

                        int r1 = v[i];
                        int r2 = v[j];

                        double bb = (r1 + r2) * (r1 + r2) - (r1 - r2) * (r1 - r2);
                        double dist = sqrt(bb);
                        dp[b | 1 << j][j] = min(dp[b | 1 << j][j], dp[b][i] + dist);
                    }
                }
            }
	    }

	    bool ans = false;
	    FOR(j, 0, dp[0].size()) {
	        if (dp[(1 << n) - 1][j] + v[j] <= W) {
	            ans = true;
	        }
	    }
	    if (ans) {
	        print("OK");
	    }
	    else {
            print("NA");
        }
	}

	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3348
final_rank: 10

code_snippet: #define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF            1e9
#define INFLL          1e18
#define EPS            1e-9
#define REP(i,n)       for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)      for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)      for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)     for(ll i=(n);i>0;--i)
#define REPC(i,obj)    for(auto i:obj)
#define ALL(obj)       (obj).begin(),(obj).end()
#define SETP(n)        cout<<fixed<<setprecision(n)
#define VV(T,h,w)      move(vector<vector<T>>(h,vector<T>(w)))
#define VVI(T,h,w,i)   move(vector<vector<T>>(h,vector<T>(w,i)))
using namespace std;
using ll = long long;
template<typename T, ll h, ll w>using vec2 = vector<vector<T>>;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

vector<ll>r;
vector<vector<double>>dp;
ll w;
unsigned n;
void init(const string&str)
{
	r.clear();
	stringstream ss(str);
	ss >> w;
	ll foo; while (ss >> foo)r.push_back(foo);
	n = r.size();
	dp = VVI(double, 1 << n, n, -1);
}
double pack(unsigned state, ll lastcake)
{
	if (state == (1 << n) - 1) return r[lastcake];
	else if (dp[state][lastcake] != -1)return dp[state][lastcake];
	else {
		double ret = INFLL;
		REP(i, n) {
			if ((state >> i & 1) == 0) {
				if (state == 0)ret = min(ret, r[i] + pack(state | (1 << i), i));
				else ret = min(ret, pack(state | (1 << i), i) + 2 * sqrt(r[lastcake] * r[i]));
			}
		}
		return dp[state][lastcake] = ret;
	}
}
signed main()
{
	string str;
	while (getline(cin, str)) {
		init(str);
		cout << (pack(0, 0) <= w ? "OK" : "NA") << endl;
	}
}
accuracy: 1
time_ms: 20
memory_kb: 4132
final_rank: 16

code_snippet: #include<iostream>
#include<ios>
#include<algorithm>
#include<cmath>
using namespace std;
double w,r[12];
double dp[1<<12][12];
main()
{
	while(~scanf("%lf ",&w))
	{
		int n=0;char c;
		while(scanf("%lf%c",r+n++,&c),c==' ');
		for(int i=0;i<n;i++)for(int j=0;j<1<<n;j++)dp[j][i]=w+1;
		for(int i=0;i<n;i++)dp[1<<i][i]=r[i];
		for(int i=1;i<1<<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(!(i&1<<j))continue;
				for(int k=0;k<n;k++)
				{
					if(i&1<<k)continue;
					double dis=2*sqrt(r[j]*r[k]);
					dp[i|(1<<k)][k]=min(dp[i|(1<<k)][k],dp[i][j]+dis);
				}
			}
		}
		double ans=w+1;
		for(int i=0;i<n;i++)ans=min(ans,dp[(1<<n)-1][i]+r[i]);
		puts(ans>w?"NA":"OK");
	}
}
accuracy: 1
time_ms: 10
memory_kb: 3408
final_rank: 2

code_snippet: #include<iostream>
#include<sstream>
#include<vector>
#include<cstring>
#include<cmath>
using namespace std;

double INF = 1000.0;

int main(){
    string s;
    while(getline(cin, s)){
        stringstream ss(s);
        int w;
        ss >> w;

        vector<double> rad;
        double next; 
        int n = 0;
        
        while(ss >> next){
            rad.push_back(next);
            n++;
        }

        double dp[n][1<<n];

        for(int i = 0; i < n; i++){
            for(int j = 0; j < 1<<n; j++){
                dp[i][j] = 10000;
            }
        }

        for(int i = 0; i < n; i++){
            dp[i][1<<i] = rad[i];
        }

        for(int s = 1; s < 1<<n; s++){
            for(int i = 0; i < n; i++){
                if(!((1<<i) & s)) continue;
                for(int j = 0; j < n; j++){
                    if((1<<j) & s)  continue;
                    double tmp = dp[i][s] + 2*sqrt(rad[i]*rad[j]);
                    if(tmp < dp[j][s | (1<<j)]){
                        dp[j][s | (1<<j)] = tmp;
                    }
                }
            }
        }

        double ans = INF;
        for(int i = 0; i < n; i++){
            ans = min(ans, dp[i][(1<<n)-1] + rad[i]);
        }

        cout << (ans <= w ? "OK" : "NA") << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3592
final_rank: 12

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e10;

int main(){
    string s;
    while(getline(cin, s)){
        stringstream buf(s);
        double w;
        buf >> w;
        vector<double> r;
        double in;
        while(buf >> in){
            r.push_back(in);
        }
        int n = r.size();

        vector<vector<double> > dp(n, vector<double>(1<<n, INF));
        for(int i=0; i<n; i++){
            dp[i][1<<i] = r[i];
        }
        for(int i=0; i<(1<<n); i++){
            for(int j=0; j<n; j++){
                if((1<<j & i) == 0) continue;
                for(int k=0; k<n; k++){
                    if((1<<k & i) != 0) continue;
                    double x = sqrt((r[j]+r[k]) *(r[j]+r[k]) - (r[j]-r[k]) *(r[j]-r[k]));
                    dp[k][i | 1<<k] = min(dp[k][i | 1<<k], dp[j][i] +x);
                }
            }
        }

        double MIN = INF;
        for(int i=0; i<n; i++){
            MIN = min(MIN, dp[i][(1<<n)-1] +r[i]);
        }
        if(MIN < w +EPS){
            cout << "OK" << endl;
        }else{
            cout << "NA" << endl;
        }
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3408
final_rank: 2

code_snippet: // ?????¬???????????¬??????

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;
constexpr double EPS = 1e-8;

double dp[1 << 12][12];

signed main() {
    string s;
    while(getline(cin, s)) {
        double W;
        stringstream ss(s);
        ss >> W;

        vector<int> v;
        int N, val;
        while(ss >> val) {
            v.push_back(val);
        }

        N = v.size();
        rep(i,0,1<<N) rep(j,0,N) dp[i][j] = INF;
        dp[0][0] = 0;

        rep(bit,0,1<<N) rep(i,0,N) {
            if(dp[bit][i] == INF) continue;
            rep(k,0,N) {
                if(bit >> k & 1) continue;
                int nbit = bit | (1 << k);
                if(__builtin_popcount(nbit) == 1) {
                    dp[nbit][k] = v[k] * 2;
                }
                else {
                    chmin(dp[nbit][k], dp[bit][i] + 2 * sqrt(v[i] * v[k]) - v[i] + v[k]);
                }
            }
        }

        bool ok = false;
        rep(i,0,N) {
            if(dp[(1<<N)-1][i] <= W + EPS) {
                cout << "OK" << endl;
                ok = true;
                break;
            }
        }
        if(!ok) cout << "NA" << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3672
final_rank: 8

code_snippet: #include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
string s;
int n;
double a[20],w;
double dp[1<<12][12];
void Input(){
  int res=0;n=-1;
  for(int i=0;i<s.size();i++){
    if(isdigit(s[i]))res=res*10+(s[i]-'0');
    if(s[i]==' '||i==s.size()-1){
      if(n==-1)w=res,n++;
      else a[n++]=res;
      res=0;
    }
  }
}
int main(){
  while(getline(cin,s)){
    Input();
    r(i,1<<12)r(j,12)dp[i][j]=1e9;
    for(int i=0;i<n;i++)dp[1<<i][i]=a[i];
    for(int i=1;i<(1<<n);i++){
      for(int j=0;j<n;j++){
	if(dp[i][j]!=1e9&&((i>>j)&1)){
	  for(int k=0;k<n;k++){
	    if(j!=k&&!((i>>k)&1)){
	      dp[i|(1<<k)][k]=min(dp[i|(1<<k)][k],dp[i][j]+2.0*sqrt(a[j]*a[k]));
	    }
	  }
	}
      }
    }
    double ans=1e9;
    for(int i=0;i<n;i++)ans=min(ans,dp[(1<<n)-1][i]+a[i]);
    if(ans<=w)cout<<"OK"<<endl;
    else cout<<"NA"<<endl;
  }
}
accuracy: 1
time_ms: 10
memory_kb: 3432
final_rank: 4

code_snippet: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <fstream>
#include <sstream>
#include <queue>
#include <exception>
#include <cmath>
#include <numeric>
#include <map>
#include <algorithm>

#define INF 100000000
#define MAX_N 12

using namespace std;
typedef long long int lint;

double dp[MAX_N][1 << MAX_N];
double d[MAX_N][MAX_N];
double rad[MAX_N];

//S : ???????????±???????????????, i : ?????????????????±??????
double rec(int S, int i, int n) {
	if (dp[i][S] < INF) return dp[i][S];

	double r = 0;

	//1????????????
	if (S == (1 << i)) {
		return dp[i][S] = rad[i];
	}

	//??¨????????????
	if (S == (1 << n) - 1) {
		r = rad[i];
	}

	double res = INF;
	//S ?????? i ??????????????????
	int SS = S ^ (1 << i);
	for (int j = 0; j < n; j++) {
		if ((SS >> j) & 1) {
			res = min(res, rec(SS, j, n) + d[j][i] + r);
		}
	}

	return dp[i][S] = res;
}

void init(int n) {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < (1 << n); j++) {
			dp[i][j] = INF + 1;
		}
	}
}

bool AOJ0120()
{
	string str;
	if (!getline(cin, str)) return false;

	istringstream iss(str);
	
	int width;
	vector<int> radii;

	iss >> width;
	int radius;
	while (iss >> radius) {
		radii.push_back(radius);
	}

	int n = radii.size();

	//init
	init(n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			d[i][j] = sqrt(radii[i] * radii[j]) * 2;
		}
		rad[i] = radii[i];
	}

	double ans = INF + 1;
	for (int i = 0; i < n; i++) {
		ans = min(ans, rec((1 << n) - 1, i, n));
	}

	if (ans < width + 1e-8) cout << "OK" << endl;
	else cout << "NA" << endl;
	
	return true;
}

int main()
{
	while (AOJ0120()) {

	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3588
final_rank: 6

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define INF 1001000100010001000
#define INFd 1010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define double long double
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define vd vector<double>
#define vvd vector<vd>

signed main()
{
    double len;
    char t;
    while (scanf("%Lf", &len) != EOF) {
        vi cake;
        while (scanf("%c", &t), t != '\n') {
            Int(tmp);
            cake.pb(tmp);
        }
        vvd dp(1 << cake.size(), vd(cake.size(), INFd));
        dp[0][0] = 0.0;


        rep(i, cake.size()) {
            int tmp = 1 << i;
            dp[tmp][i] = cake[i];
        }

        rep(i, 1 << cake.size()) {
            rep(j, cake.size()) {
                if (i & (1 << j)) {
                    rep(k, cake.size()) {
                        if (!(i & (1 << k))) {
                            dp[i|(1 << k)][k] = min(dp[i|(1 << k)][k],
                                    dp[i][j] + 
                                    sqrt( (double)((cake[j]+cake[k])*(cake[j]+cake[k]) - 
                                            (cake[k]-cake[j])*(cake[k]-cake[j])) ));
                        }
                    }
                }
            }
        }
        bool ans = false;
        rep(i, cake.size()) {
            if (len >= dp[(1 << cake.size())-1][i] + (double)cake[i]) {
                ans = true;
                break;
            }
        }
        cout << ( (ans) ? "OK" : "NA" ) << endl;
    }

    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3960
final_rank: 14

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define INF 1001000100010001000
#define INFd 1010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define double long double
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define vd vector<double>
#define vvd vector<vd>

 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign


void mmprint(int a)
{
    string st;
    if (!a) cout << 0 << " ";
    else {
        while (a) {
            st.pb((a&1)+'0');
            a >>= 1;
        }
        reverse(all(st));
        cout << st << " ";
    }
}
 
signed main()
{
    double len;
    char t;
    while (scanf("%Lf", &len) != EOF) {
        vi cake;
        while (scanf("%c", &t), t != '\n') {
            Int(tmp);
            cake.pb(tmp);
        }
        if (!cake.size()) {
            cout << "OK" << endl;
            continue;
        }
        vvd dp(1 << cake.size(), vd(cake.size(), INFd));
        dp[0][0] = 0.0;
 
        
        rep(i, cake.size()) {
            int tmp = 1 << i;
            dp[tmp][i] = cake[i];
        }
        
        rep(i, 1 << cake.size()) {
           // mmprint(i);
            rep(j, cake.size()) {
                if (i & (1 << j)) {
                    //cout << "sento:" << j << " ";
                    rep(k, cake.size()) {
                        if (!(i & (1 << k))) {
                            //cout << "tsuika" << k << " ";
                            //cout << "tsuikasaki" << (i|(1 << k)) << " ";
                            dp[i|(1 << k)][k] = min(dp[i|(1 << k)][k],
                                    dp[i][j] + 
        sqrt( (double)((cake[j]+cake[k])*(cake[j]+cake[k])-
                (cake[k]-cake[j])*(cake[k]-cake[j])) ));
                        }
                    }
                }
            }
            //cout << endl;
        }
        rep(i, 1 << cake.size()) {
            //mmprint(i);
            rep(j, cake.size()) {
                //cout << dp[i][j] << " ";
            }
            //cout << endl;
        }
        bool ans = false;
        rep(i, cake.size()) {
            if (len >= dp[(1 << cake.size())-1][i] + (double)cake[i]) {
                ans = true;
                break;
            }
        }
        cout << ( (ans) ? "OK" : "NA" ) << endl;
    }



    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 4060
final_rank: 15