結果

問題 No.2334 Distinct Cards
ユーザー batapi0311batapi0311
提出日時 2023-06-02 21:44:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 2,924 bytes
コンパイル時間 1,822 ms
コンパイル使用メモリ 184,488 KB
実行使用メモリ 14,224 KB
最終ジャッジ日時 2023-08-28 03:03:54
合計ジャッジ時間 3,975 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 109 ms
10,380 KB
testcase_13 AC 104 ms
10,424 KB
testcase_14 AC 102 ms
10,516 KB
testcase_15 AC 103 ms
10,440 KB
testcase_16 AC 106 ms
10,504 KB
testcase_17 AC 150 ms
14,156 KB
testcase_18 AC 148 ms
14,224 KB
testcase_19 AC 142 ms
14,172 KB
testcase_20 AC 28 ms
4,380 KB
testcase_21 AC 28 ms
4,376 KB
testcase_22 AC 28 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

#define V vector<ll>
#define Vi vector<int>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define VV vector<V>
using P = pair<ll,ll>;
using G = vector<vector<int>>;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define INF 1LL << 60
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

long long combi(long long n, long long k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}
//整数かどうか
bool isNumber(const string& str)
{
  for (const char &c : str) {
        if (std::isdigit(c) == 0) return false;
    }
    return true;
}
//最大公約数
int gcd(int a, int b){
  if(a%b == 0){
    return b;
  }else{
    return gcd(b, a%b);
  }
}
//最小公倍数
int lcm(int a, int b){
  return a*b / gcd(a, b);
}

//int di[] = {-1,0,1,0};
//int dj[] = {0,-1,0,1};

//s = regex_replace(s, regex("あ"), "う");
/*stiring で char を検索するときは
    s.find(c)!=string::npos
 */


/*//各桁の和
 int wa(int n){
  int sum =0;
  while(n>0){
    sum += n%10;
    n/=10;
  }
  return sum;
}
*/

/*//階乗
 int ki(int i){
   int k = 1;
   for(int j = 1; j<=i; j++){
     k *= j;
   }
   return k;
 }
 */
/*log_x(b)
double logN(double x, double b) {
    return log(x) / log(b);
}
*/

/*//エラトステネスの篩 main関数内にsolve();を書き込め!!
const ll N = 1010101;//求める範囲
Vb isp(N+1,true);
void solve(){
  isp[0] = false;
  isp[1] = false;
  for(ll i = 2; i+i<=N;i++){
    if(isp[i])for(ll j = 2; i*j<=N;j++)isp[i*j] = false;
  }
}
*/


//vector<int> dx = {1,0,-1,0,1,-1,-1,1};
//vector<int> dy = {0,1,0,-1,1,1,-1,-1};
//int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
//#define mod 998244353
//using mint = modint1000000007;
//cout << mint.val() << endl;
//using mint = modint998244353;
//cout << fixed << setprecision(15) << y << endl;
#define yes "Yes"
#define no "No"
#define Yes "YES"
#define No "NO"

int main(){
  int n,k;
  cin >> n >> k;
  V a(n);
  vector <pair<int,int>> pa;
  set<int>st;
  map<int,int>mp;
  rep(i,n){
    int a;
    cin >> a;
    st.insert(a);
    mp[a]++;
  }
  for(auto e : st){
    pa.push_back(make_pair(mp[e],e));
  }
  sort(all(pa));
  reverse(all(pa));
  int i = 0;
  for(auto e : pa){
   k-=e.first;
   i++;
   //cout << k << endl;
   if(k<=0)break;
  }
  cout << i << endl;



  //cout << st.size() << endl;
}


0