結果

問題 No.914 Omiyage
ユーザー soto800soto800
提出日時 2019-10-25 21:38:34
言語 C++11
(gcc 13.3.0)
結果
MLE  
実行時間 -
コード長 986 bytes
コンパイル時間 1,378 ms
コンパイル使用メモリ 163,952 KB
実行使用メモリ 1,222,276 KB
最終ジャッジ日時 2024-07-22 23:09:31
合計ジャッジ時間 7,836 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other MLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

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