結果

問題 No.247 線形計画問題もどき
ユーザー syoken_desukasyoken_desuka
提出日時 2015-07-18 01:20:13
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,265 bytes
コンパイル時間 571 ms
コンパイル使用メモリ 85,396 KB
実行使用メモリ 82,212 KB
最終ジャッジ日時 2023-09-22 18:49:31
合計ジャッジ時間 2,384 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
81,476 KB
testcase_01 AC 24 ms
81,736 KB
testcase_02 WA -
testcase_03 AC 24 ms
81,540 KB
testcase_04 AC 24 ms
81,532 KB
testcase_05 AC 25 ms
81,452 KB
testcase_06 AC 24 ms
81,528 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 25 ms
81,620 KB
testcase_10 WA -
testcase_11 AC 24 ms
81,620 KB
testcase_12 AC 24 ms
81,456 KB
testcase_13 AC 24 ms
81,736 KB
testcase_14 AC 24 ms
81,476 KB
testcase_15 AC 23 ms
81,616 KB
testcase_16 AC 24 ms
81,540 KB
testcase_17 AC 27 ms
81,552 KB
testcase_18 AC 25 ms
81,528 KB
testcase_19 AC 33 ms
82,000 KB
testcase_20 AC 35 ms
82,160 KB
testcase_21 AC 25 ms
81,540 KB
testcase_22 AC 25 ms
81,732 KB
testcase_23 AC 25 ms
81,720 KB
testcase_24 AC 36 ms
81,600 KB
testcase_25 AC 31 ms
81,776 KB
testcase_26 AC 25 ms
81,616 KB
testcase_27 AC 27 ms
81,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <array>
#include <sstream>
#include <cstdio>
#include <functional>
#include <cstdlib>
#include <cctype>
#include <ostream>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

#define MOD 1000000007


int main()
{  
    int c,n;
    int a[100];
    ll dp[101][100001];
    cin >> c >> n; 
    fill(a,a+100,-1);//invalid error on sort
    rep(i,n)
    {
        cin >> a[i];
    }
    rep(i,100)
    {
        rep(j,100000)
        {
            dp[i][j] = 1000000;
        }
    }
    dp[0][0] = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < c+1; j++)
        {
            if (j < a[i])
            {
                dp[i+1][j]= dp[i][j];
            } else
            {
                dp[i+1][j] = min(dp[i][j], dp[i+1][max(0,j-a[i])] + 1 );
            }
        }
    }
    if (dp[n][c] != 1000000)
    {
        cout << dp[n][c] << endl;
        return 0;
    }
    cout << "-1" << endl;
    return 0;
}


0