結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int N,K;cin>>N>>K;
    map<int,int>mp;
    vector<int>vec(N);
    set<int>st;
    for(int i=0; i<N; i++){
        cin>>vec[i];
        st.insert(vec[i]);
        mp[vec[i]]++;
    }
    vector<int>ans;
    for(int i:st){
        ans.push_back(i);
    }
    sort(ans.rbegin(),ans.rend());
    int anss=1000,a=0,b=0;
    for(int i:ans){
        a+=mp[i];
        if(a<=K){
            anss=min(anss,i);
            b+=mp[i];
        }
    }
    cout<<b<<endl;
}
0