結果

問題 No.2334 Distinct Cards
ユーザー yicode
提出日時 2023-06-11 17:50:01
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 536 bytes
コンパイル時間 1,829 ms
コンパイル使用メモリ 171,400 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2025-01-03 04:01:42
合計ジャッジ時間 3,907 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:20: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   13 |   for (const auto& [key, value] : dic) {
      |                    ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
int main() {
  int N,K; cin >> N >> K;
  map<int,int> dic;
  for(int i = 0; i < N; i++) {
    int a; cin >> a;
    dic[a]++;
  }
  vector<int> a;
  for (const auto& [key, value] : dic) {
   a.push_back(value);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int ans = 0;
  int y = 0;
  for(int i = 0; i < a.size();i++){
    ans += a[i];
    y++;
    if(ans >= K) {
      
      break;
    }
  }
  cout << y << endl;
}
0