結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
_yoshih_
|
| 提出日時 | 2018-09-19 23:38:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 755 bytes |
| コンパイル時間 | 711 ms |
| コンパイル使用メモリ | 79,180 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-18 12:37:07 |
| 合計ジャッジ時間 | 1,515 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
static void setup()
{
cin.tie(0);
ios::sync_with_stdio(false);
}
static void run()
{
int l, n;
cin >> l >> n;
map<int, int> ws;
for (auto i = 0; i < n; ++i) {
int w;
cin >> w;
ws[w] += 1;
}
auto rl = 0;
auto rn = 0;
for (auto wp : ws) {
const auto wl = wp.first * wp.second;
if (rl + wl > l) {
const auto tn = (l - rl) / wp.first;
rn += tn;
break;
}
else {
rl += wl;
rn += wp.second;
}
}
cout << rn << endl;
}
int main(int argc, char **argv)
{
setup();
run();
return 0;
}
_yoshih_