結果
問題 | No.247 線形計画問題もどき |
ユーザー |
![]() |
提出日時 | 2019-03-07 18:55:15 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 565 bytes |
コンパイル時間 | 1,310 ms |
コンパイル使用メモリ | 161,364 KB |
実行使用メモリ | 83,220 KB |
最終ジャッジ日時 | 2024-06-23 14:52:13 |
合計ジャッジ時間 | 3,241 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 18 WA * 5 |
ソースコード
#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; }