結果
| 問題 |
No.156 キャンディー・ボックス
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2020-01-07 23:17:54 |
| 言語 | cLay (20241019-1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 447 bytes |
| コンパイル時間 | 1,974 ms |
| コンパイル使用メモリ | 175,628 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-05 13:31:03 |
| 合計ジャッジ時間 | 2,491 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 15 WA * 15 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int n,m;cin>>n>>m;
vector<int> a(n);
for(int i = 0; n > i; i++){
cin>>a[i];
}
int ans = 0;
sort(a.begin(),a.end());
for(int i = 0; 1; i++){
if(m >= a[i]){
ans++;
m -= a[i];
a[i] = 0;
}else{
cout << ans << endl;
return 0;
}
}
}