結果

問題 No.247 線形計画問題もどき
ユーザー oxyshoweroxyshower
提出日時 2019-03-07 18:55:15
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 565 bytes
コンパイル時間 1,267 ms
コンパイル使用メモリ 145,832 KB
実行使用メモリ 83,356 KB
最終ジャッジ日時 2023-09-05 19:28:01
合計ジャッジ時間 3,207 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 26 ms
83,128 KB
testcase_02 AC 54 ms
83,264 KB
testcase_03 AC 26 ms
83,116 KB
testcase_04 AC 26 ms
83,116 KB
testcase_05 AC 25 ms
83,060 KB
testcase_06 AC 26 ms
83,068 KB
testcase_07 AC 27 ms
83,044 KB
testcase_08 AC 26 ms
83,188 KB
testcase_09 AC 25 ms
83,084 KB
testcase_10 AC 25 ms
83,124 KB
testcase_11 AC 26 ms
83,116 KB
testcase_12 AC 25 ms
83,076 KB
testcase_13 AC 25 ms
83,116 KB
testcase_14 AC 25 ms
83,076 KB
testcase_15 AC 25 ms
83,072 KB
testcase_16 AC 25 ms
83,136 KB
testcase_17 WA -
testcase_18 AC 25 ms
83,200 KB
testcase_19 WA -
testcase_20 AC 37 ms
83,080 KB
testcase_21 AC 27 ms
83,068 KB
testcase_22 AC 28 ms
83,120 KB
testcase_23 AC 27 ms
83,092 KB
testcase_24 AC 36 ms
83,052 KB
testcase_25 AC 34 ms
83,096 KB
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long

const int MOD = 1e9+7;
const int INF = 1LL << 60;

int dp[101][101010];

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int C,N; cin >> C >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }

  fill(dp[0],dp[100]+101010,INF);
  dp[0][0] = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j <= C; j++){
      dp[i+1][j] = min(dp[i][j],dp[i+1][j-a[i]]+1);
    }
  }
  if(dp[N][C] == INF) cout << -1 << endl;
  else cout << dp[N][C] << endl;

  return 0;
}
0