結果

問題 No.914 Omiyage
ユーザー fura
提出日時 2020-05-15 12:56:27
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 387 bytes
コンパイル時間 2,671 ms
コンパイル使用メモリ 191,804 KB
最終ジャッジ日時 2025-01-10 11:06:21
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         int n,m,k; scanf("%d%d%d",&n,&m,&k);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:13:37: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |                         int a; scanf("%d",&a);
      |                                ~~~~~^~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,m,k; scanf("%d%d%d",&n,&m,&k);
	bool dp[501]={true};
	rep(i,n){
		bool next[501]={};
		rep(j,m){
			int a; scanf("%d",&a);
			rep(w,k-a+1) if(dp[w]) next[w+a]=true;
		}
		copy(next,next+k+1,dp);
	}

	int res=k+1;
	rep(w,k+1) if(dp[w]) res=w;
	printf("%d\n",k-res);

	return 0;
}
0