結果

問題 No.247 線形計画問題もどき
ユーザー syoken_desukasyoken_desuka
提出日時 2015-07-18 00:53:51
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,742 bytes
コンパイル時間 603 ms
コンパイル使用メモリ 89,480 KB
実行使用メモリ 44,620 KB
最終ジャッジ日時 2023-09-22 18:46:51
合計ジャッジ時間 2,222 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
44,328 KB
testcase_01 AC 15 ms
44,332 KB
testcase_02 AC 41 ms
44,328 KB
testcase_03 AC 16 ms
44,396 KB
testcase_04 AC 16 ms
44,328 KB
testcase_05 WA -
testcase_06 AC 16 ms
44,400 KB
testcase_07 AC 16 ms
44,320 KB
testcase_08 AC 16 ms
44,408 KB
testcase_09 AC 15 ms
44,500 KB
testcase_10 AC 16 ms
44,336 KB
testcase_11 AC 16 ms
44,616 KB
testcase_12 WA -
testcase_13 AC 15 ms
44,548 KB
testcase_14 AC 16 ms
44,548 KB
testcase_15 AC 16 ms
44,620 KB
testcase_16 WA -
testcase_17 AC 18 ms
44,332 KB
testcase_18 AC 16 ms
44,320 KB
testcase_19 AC 22 ms
44,356 KB
testcase_20 AC 24 ms
44,348 KB
testcase_21 WA -
testcase_22 AC 18 ms
44,396 KB
testcase_23 WA -
testcase_24 AC 25 ms
44,480 KB
testcase_25 AC 23 ms
44,616 KB
testcase_26 AC 17 ms
44,492 KB
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long ll;

#define PI acos(-1)
#define EPS 0.000000001
#define MOD 1000000007


int main()
{  
    int dp[105][100001];
    int c;
    int n;
    int a[100];
    cin >> c >> n;
    fill(a,a+100,-1);//invalid error on sort
    rep(i,105)
    {
        rep(j,100001)
        {
            dp[i][j] = 10000000;
        }
    }
    rep(i,n)
    {
        cin >> a[i];
    }
    //sort(a,a+100,greater<int>());
    dp[0][0] = 0;
    //RE???????????????????????????????????????????????????????????????????????????????????
    //aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    //ぼくのかんきょうだと うごくのに うごかない これがわからない
    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][j-a[i]]+1);
            }
        }
    }

    if (dp[n][c]!= MOD)
    {
        cout << dp[n][c] << endl;
        return 0;
    }
    cout << "-1" << endl;
    return 0;
}


0