結果

問題 No.914 Omiyage
ユーザー soto800soto800
提出日時 2019-10-25 21:38:34
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 986 bytes
コンパイル時間 1,568 ms
コンパイル使用メモリ 150,616 KB
実行使用メモリ 617,624 KB
最終ジャッジ日時 2023-09-30 05:13:07
合計ジャッジ時間 8,347 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

signed main(){
 
	lli n,m,k;
	cin>>n>>m>>k;

	lli dp[600];

	REP(i,0,600)dp[i]=0;

	dp[0]=1;

	priority_queue<lli> q;

	q.push(0);
	REP(i,0,n){
		vector<lli> a(m);
		REP(j,0,m)cin>>a[j];

		priority_queue<lli> next;

		while(q.size()){
			lli now=q.top();
			if(DEBUG)cout<<"nowTop="<<now<<endl;
			q.pop();
			REP(j,0,m){
				lli plus = a[j];
				if(DEBUG)cout<<"plus="<<plus<<endl;
				if(now+plus<=k){
					if(DEBUG)cout<<"nextPush="<<now+plus<<endl;
					next.push(now+plus);
				}
			}
		}

		while(next.size()){
			lli now = next.top();
			q.push(now);
			next.pop();
		}
	}

	while(q.size()){
		lli top = q.top();
		q.pop();
		if(top<=k){
			cout<<k-top<<endl;
			return 0;
		}
	}

	cout<<-1<<endl;
 
	return 0;
}
0