結果
問題 | No.247 線形計画問題もどき |
ユーザー |
![]() |
提出日時 | 2015-07-18 01:44:01 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 96 ms / 2,000 ms |
コード長 | 663 bytes |
コンパイル時間 | 1,116 ms |
コンパイル使用メモリ | 67,328 KB |
実行使用メモリ | 31,384 KB |
最終ジャッジ日時 | 2024-07-07 11:04:45 |
合計ジャッジ時間 | 1,633 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 23 |
ソースコード
#include <iostream> #include <algorithm> #include <string.h> #include <queue> using namespace std; typedef long long ll; typedef pair<int,int> ii; int dp[100001]; int main() { int n,m; cin>>n>>m; int niza[m]; for(int ctr1=0;ctr1<m;ctr1++){ cin>>niza[ctr1]; } memset(dp,-1,sizeof(dp)); queue<ii> kju; kju.push({0,0}); while(!kju.empty()){ ii p=kju.front(); kju.pop(); if(p.first>n || dp[p.first]!=-1) continue; dp[p.first]=p.second; for(int ctr1=0;ctr1<m;ctr1++) kju.push({p.first+niza[ctr1],p.second+1}); } cout<<dp[n]<<endl; return 0; }