結果

問題 No.2334 Distinct Cards
ユーザー SSRS
提出日時 2021-09-30 23:24:07
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 526 bytes
コンパイル時間 2,046 ms
コンパイル使用メモリ 173,892 KB
実行使用メモリ 17,536 KB
最終ジャッジ日時 2024-12-28 15:53:54
合計ジャッジ時間 45,583 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 8 TLE * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
    A[i]--;
  } 
  vector<int> p(N, 0);
  for (int i = 0; i < K; i++){
    p[N - 1 - i] = 1;
  }
  int ans = N;
  while (true){
    set<int> st;
    for (int i = 0; i < N; i++){
      if (p[i] == 1){
        st.insert(A[i]);
      }
    }
    ans = min(ans, (int) st.size());
    if (!next_permutation(p.begin(), p.end())){
      break;
    }
  }
  cout << ans << endl;
}
0