結果
| 問題 | 
                            No.1380 Borderline
                             | 
                    
| コンテスト | |
| ユーザー | 
                             SSRS
                         | 
                    
| 提出日時 | 2021-02-07 20:34:00 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 407 bytes | 
| コンパイル時間 | 1,593 ms | 
| コンパイル使用メモリ | 171,308 KB | 
| 実行使用メモリ | 6,940 KB | 
| 最終ジャッジ日時 | 2024-07-04 13:38:08 | 
| 合計ジャッジ時間 | 2,779 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 39 WA * 2 | 
ソースコード
#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 (K == N){
    cout << N << endl;
  } else if (p[K - 1] == p[0]){
    cout << 0 << endl;
  } else {
    int ans = K;
    while (p[ans - 1] == p[ans]){
      ans--;
    }
    cout << ans << endl;
  }
}
            
            
            
        
            
SSRS