結果
問題 |
No.156 キャンディー・ボックス
|
ユーザー |
![]() |
提出日時 | 2017-03-26 15:12:44 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 599 bytes |
コンパイル時間 | 1,451 ms |
コンパイル使用メモリ | 162,412 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-06 06:29:18 |
合計ジャッジ時間 | 2,285 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 WA * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define INF 2000000000 #define MOD 1000000007 typedef long long ll; typedef pair<int, int> P; int main() { int n,m; cin >> n>>m; int c[n]; for (int i = 0; i < n; i++) { cin >> c[i]; } sort(c,c+n); int tmp = 0; int idx = 0; int ret = 0; while (true) { tmp += c[idx]; if (idx>=n) { cout << n << "\n"; return 0; } if (c[idx]==c[idx+1]) { idx++; continue; } if (tmp<=m) { m -= tmp; // cout << tmp/c[idx] << "\n"; ret += tmp/c[idx]; tmp = 0; idx++; } else { break; } } cout << ret << endl; }