結果

問題 No.527 ナップサック容量問題
ユーザー firiexpfiriexp
提出日時 2019-08-25 18:03:59
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 844 bytes
コンパイル時間 603 ms
コンパイル使用メモリ 84,640 KB
最終ジャッジ日時 2023-08-09 21:16:49
合計ジャッジ時間 1,499 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:23:24: エラー: variable ‘std::array<int, 100001> a’ has initializer but incomplete type
   23 |     array<int, 100001> a{};
      |                        ^

ソースコード

diff #

#include <limits>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    array<int, 100001> a{};
    for (int i = 0; i < n; ++i) {
        int v, w; cin >> v >> w;
        for (int j = 100000; j >= w; --j) {
            a[j] = max(a[j], a[j-w]+v);
        }
    }
    int V; cin >> V;
    cout << max(1, static_cast<int>(lower_bound(a.begin(),a.end(), V) - a.begin())) << "\n";
    if(a.back() == V) puts("inf");
    else cout << upper_bound(a.begin(),a.end(), V) - a.begin()-1 << "\n";
    return 0;
}
0