結果

問題 No.1380 Borderline
ユーザー SSRS
提出日時 2021-02-07 20:33:16
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 407 bytes
コンパイル時間 1,557 ms
コンパイル使用メモリ 170,896 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-04 13:37:38
合計ジャッジ時間 2,785 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 37 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  for (int i = 0; i < N; i++){
    cin >> p[i];
  }
  sort(p.begin(), p.end(), greater<int>());
  if (p[K - 1] == p[0]){
    cout << 0 << endl;
  } else if (K == N){
    cout << N << endl;
  } else {
    int ans = K;
    while (p[ans - 1] == p[ans]){
      ans--;
    }
    cout << ans << endl;
  }
}
0