#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 20;
int dp[1<<N];
int a[N];
int n , x;
int getSum(int mask){
int sum = 0;
for(int i = 0;i<n;i++){
if(mask & (1<<i)){
sum += a[i];
}
}
return sum;
}
int solve(int mask){
if(mask == ((1<<n) - 1)){
return 0;
}
if(dp[mask]!=-1)
return dp[mask];
int ans = INT_MAX;
int sum = getSum(mask);
int rem = sum%x;
int prev = sum/x + (rem > 0);
for(int i = 0;i<n;i++){
if(mask & (1<<i)) continue;
int newSum = sum + a[i];
int curr = (newSum/x) + ((newSum%x) > 0);
ans = min(ans , (curr > prev) + solve(mask|(1<<i)));
}
dp[mask] = ans;
return ans;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
memset(dp,-1,sizeof(dp));
cin >> n >> x;
for(int i = 0;i<n;i++){
cin >> a[i];
}
cout<<solve(0);
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBpbnQgbG9uZyBsb25nCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGludCBOID0gMjA7CmludCBkcFsxPDxOXTsKaW50IGFbTl07CmludCBuICwgeDsKaW50IGdldFN1bShpbnQgbWFzayl7CglpbnQgc3VtID0gMDsKCWZvcihpbnQgaSA9IDA7aTxuO2krKyl7CgkJaWYobWFzayAmICgxPDxpKSl7CgkJCXN1bSArPSBhW2ldOwoJCX0KCX0KCXJldHVybiBzdW07Cn0KaW50IHNvbHZlKGludCBtYXNrKXsKCWlmKG1hc2sgPT0gKCgxPDxuKSAtIDEpKXsKCQlyZXR1cm4gMDsKCX0KCWlmKGRwW21hc2tdIT0tMSkKCQlyZXR1cm4gZHBbbWFza107CglpbnQgYW5zID0gSU5UX01BWDsKCWludCBzdW0gPSBnZXRTdW0obWFzayk7CglpbnQgcmVtID0gc3VtJXg7CglpbnQgcHJldiA9IHN1bS94ICsgKHJlbSA+IDApOwoJZm9yKGludCBpID0gMDtpPG47aSsrKXsKCQlpZihtYXNrICYgKDE8PGkpKSBjb250aW51ZTsKCQlpbnQgbmV3U3VtID0gc3VtICsgYVtpXTsKCQlpbnQgY3VyciA9IChuZXdTdW0veCkgKyAoKG5ld1N1bSV4KSA+IDApOwoJCWFucyA9IG1pbihhbnMgLCAoY3VyciA+IHByZXYpICsgc29sdmUobWFza3woMTw8aSkpKTsKCX0KCWRwW21hc2tdID0gYW5zOwoJcmV0dXJuIGFuczsKfQpzaWduZWQgbWFpbigpewoJaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsKCWNpbi50aWUoMCk7Y291dC50aWUoMCk7CgltZW1zZXQoZHAsLTEsc2l6ZW9mKGRwKSk7CgljaW4gPj4gbiA+PiB4OwoJZm9yKGludCBpID0gMDtpPG47aSsrKXsKCQljaW4gPj4gYVtpXTsKCX0KCWNvdXQ8PHNvbHZlKDApOwp9
Main.java:1: error: illegal character: '#'
#include<bits/stdc++.h>
^
Main.java:1: error: class, interface, or enum expected
#include<bits/stdc++.h>
^
Main.java:2: error: illegal character: '#'
#define int long long
^
Main.java:4: error: class, interface, or enum expected
const int N = 20;
^
Main.java:5: error: class, interface, or enum expected
int dp[1<<N];
^
Main.java:6: error: class, interface, or enum expected
int a[N];
^
Main.java:7: error: class, interface, or enum expected
int n , x;
^
Main.java:8: error: class, interface, or enum expected
int getSum(int mask){
^
Main.java:10: error: class, interface, or enum expected
for(int i = 0;i<n;i++){
^
Main.java:10: error: class, interface, or enum expected
for(int i = 0;i<n;i++){
^
Main.java:10: error: class, interface, or enum expected
for(int i = 0;i<n;i++){
^
Main.java:13: error: class, interface, or enum expected
}
^
Main.java:16: error: class, interface, or enum expected
}
^
Main.java:20: error: class, interface, or enum expected
}
^
Main.java:23: error: class, interface, or enum expected
int ans = INT_MAX;
^
Main.java:24: error: class, interface, or enum expected
int sum = getSum(mask);
^
Main.java:25: error: class, interface, or enum expected
int rem = sum%x;
^
Main.java:26: error: class, interface, or enum expected
int prev = sum/x + (rem > 0);
^
Main.java:27: error: class, interface, or enum expected
for(int i = 0;i<n;i++){
^
Main.java:27: error: class, interface, or enum expected
for(int i = 0;i<n;i++){
^
Main.java:27: error: class, interface, or enum expected
for(int i = 0;i<n;i++){
^
Main.java:29: error: class, interface, or enum expected
int newSum = sum + a[i];
^
Main.java:30: error: class, interface, or enum expected
int curr = (newSum/x) + ((newSum%x) > 0);
^
Main.java:31: error: class, interface, or enum expected
ans = min(ans , (curr > prev) + solve(mask|(1<<i)));
^
Main.java:32: error: class, interface, or enum expected
}
^
Main.java:34: error: class, interface, or enum expected
return ans;
^
Main.java:35: error: class, interface, or enum expected
}
^
Main.java:38: error: class, interface, or enum expected
cin.tie(0);cout.tie(0);
^
Main.java:38: error: class, interface, or enum expected
cin.tie(0);cout.tie(0);
^
Main.java:39: error: class, interface, or enum expected
memset(dp,-1,sizeof(dp));
^
Main.java:40: error: class, interface, or enum expected
cin >> n >> x;
^
Main.java:41: error: class, interface, or enum expected
for(int i = 0;i<n;i++){
^
Main.java:41: error: class, interface, or enum expected
for(int i = 0;i<n;i++){
^
Main.java:41: error: class, interface, or enum expected
for(int i = 0;i<n;i++){
^
Main.java:43: error: class, interface, or enum expected
}
^
Main.java:45: error: class, interface, or enum expected
}
^
36 errors