#include using namespace std; int main(){ size_t n,k; cin >> n >> k; //整数の個数をカウント map M; for(size_t i=0;i> a; M[a]++; } //個数⇒整数(個数の多いほうから) map, greater> IM; for(pair p : M){ #ifdef DEBUG cout << p.first << ' ' << p.second << endl << flush; #endif IM[p.second].push_back(p.first); } size_t count=0; //合計枚数 int cnt=0; //種類数 for(pair> p : IM){ for(int i : p.second){ #ifdef DEBUG cout << p.first << ' ' << i << endl << flush; #endif count+=p.first; cnt++; if(count>=k){ break; } } if(count>=k){ break; } } //最小の種類数を出力 cout << cnt << endl; }