結果

問題 No.914 Omiyage
ユーザー 👑 CleyLCleyL
提出日時 2020-01-29 02:01:16
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 478 bytes
コンパイル時間 737 ms
コンパイル使用メモリ 72,036 KB
実行使用メモリ 17,088 KB
最終ジャッジ日時 2024-09-15 16:32:13
合計ジャッジ時間 7,103 ms
ジャッジサーバーID
(参考情報)
judge1 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other TLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
vector<vector<int> > A(11,vector<int>(11));
int n,m,k;
int DFS(int nw,int c){
  if(c > k){return -1;};
  if(nw == n){
    return c;
  }
  int ans = -1;
  for(int i = 0; m > i; i++){
    ans = max(ans,DFS(nw+1,c+A[nw][i]));
  }
  return ans;
}

int main(){
  cin>>n>>m>>k;
  for(int i = 0; n > i; i++){
    for(int j = 0; m > j; j++){
      cin>>A[i][j];
    }
  }
  int z = DFS(0,0);
  cout << (z==-1?-1:k-z) << endl;
}
0