結果

問題 No.54 Happy Hallowe'en
ユーザー ss_koishiss_koishi
提出日時 2014-11-06 16:18:01
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 568 bytes
コンパイル時間 653 ms
コンパイル使用メモリ 51,344 KB
実行使用メモリ 10,740 KB
最終ジャッジ日時 2023-08-29 00:46:26
合計ジャッジ時間 7,163 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,764 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 TLE -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#define INF (2 << 24)
using namespace std;

int n, v[11111], t[11111];
int dp[10001][10001];

int rec(int sum, int home){

  if(dp[sum][home]) return dp[sum][home];
  int ret = 0;
  bool judge = true;
  for(int i = 0; i < n; i++){
    if(sum < t[i]){
      ret = max(ret, rec(sum + v[i], home + 1) + v[i]);
      judge = false;
    }
  }
  if(judge) return 0;
  return dp[sum][home] = ret;
}
    
int main(){
  
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> v[i] >> t[i];
  }
  
  cout << rec(0, 0) << endl;
}
0