結果

問題 No.2424 Josouzai
ユーザー twooimp
提出日時 2023-08-18 21:02:47
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 345 bytes
コンパイル時間 1,669 ms
コンパイル使用メモリ 171,592 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-28 04:40:12
合計ジャッジ時間 4,565 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);
  for(ll i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  ll mx=0,rem=k;
  for(ll i=0;i<n;i++){
    if(rem>0){
      if(rem>=a[i]){
        rem-=a[i];
        mx++;
      }
    }
  }
  cout<<mx<<" "<<rem<<endl;
}
0