結果
問題 | No.5 数字のブロック |
ユーザー |
|
提出日時 | 2019-09-09 07:27:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 5,000 ms |
コード長 | 560 bytes |
コンパイル時間 | 1,584 ms |
コンパイル使用メモリ | 171,560 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 01:14:23 |
合計ジャッジ時間 | 2,728 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
/** @file 005.cpp @title No.5 数字のブロック - yukicoder @url https://yukicoder.me/problems/no/5 **/ #include <bits/stdc++.h> using namespace std; typedef long long LL; #define ALL(obj) (obj).begin(), (obj).end() #define REP(i, N) for (int i = 0; i < (N); ++i) int main() { int L, N; cin >> L >> N; vector<int> W(N, 0); REP(i, N) { cin >> W[i]; } sort(ALL(W)); int ans = 0; REP(i, N) { if (L - W[i] >= 0) { L -= W[i]; ans = i + 1; } else { break; } } cout << ans << endl; return 0; }