Pagini recente » Cod sursa (job #9364) | Cod sursa (job #2380844) | Cod sursa (job #989816) | Cod sursa (job #828898) | Cod sursa (job #2393092)
//ALEX ENACHE
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <time.h>
#include <iomanip>
#include <deque>
#include <math.h>
#include <cmath>
#include <assert.h>
#include <stack>
#include <bitset>
#include <random>
#include <chrono>
using namespace std;
//#include <iostream>
#include <fstream>
ifstream cin ("ghiozdan.in");ofstream cout ("ghiozdan.out");
int fv[210];
int last[75100];
int dp[75100];
const int inf = 1e9;
int main() {
//freopen("input", "r", stdin);freopen("output", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cout << setprecision(10) << fixed;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
srand(time(NULL));
int n , g;
cin>>n>>g;
for (int i=1; i<=n; i++){
int x;
cin>>x;
fv[x]++;
}
for (int i=1; i<=g; i++){
last[i] = -1;
}
for (int i=200; i>=1; i--){
for (int j=g; j>=0; j--){
if (last[j] == -1){
continue;
}
for (int k=j+i; k<=min(j+i*fv[i] , g); k+=i){
if (last[k] != -1){
break;
}
last[k] = j;
dp[k] = dp[j]+(k-j)/i;
}
}
}
int now = 0;
for (int i=0; i<=g; i++){
if (last[i] != -1){
now = i;
}
}
cout<<now<<" "<<dp[now]<<'\n';
while (now){
int add = dp[now] - dp[last[now]];
int dif = now - last[now];
for (int i=1; i<=add; i++){
cout<<dif/add<<'\n';
}
now = last[now];
}
return 0;
}