結果

問題 No.54 Happy Hallowe'en
ユーザー ss_koishiss_koishi
提出日時 2014-11-06 17:08:31
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 708 bytes
コンパイル時間 725 ms
コンパイル使用メモリ 73,932 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 01:37:16
合計ジャッジ時間 2,911 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 55 ms
4,376 KB
testcase_05 AC 82 ms
4,376 KB
testcase_06 AC 112 ms
4,376 KB
testcase_07 AC 151 ms
4,376 KB
testcase_08 AC 183 ms
4,376 KB
testcase_09 AC 221 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 187 ms
4,376 KB
testcase_13 AC 202 ms
4,376 KB
testcase_14 WA -
testcase_15 AC 2 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#define INF (2 << 24)
using namespace std;

int n;
bool dp[20001];
bool chk[10001];
vector <pair<int, int> > vt;

    
int main(){
  
  cin >> n;
  for(int i = 0; i < n; i++){
    int v, t; cin >> v >> t;
    vt.push_back(make_pair(v, t));
  }

  sort(vt.begin(), vt.end());
  memset(chk, true, sizeof(chk));
  
  dp[0] = true; 
  for(int j = 0; j < n; j++){
    for(int i = 0; i <= 20000; i++){ 
      if(dp[i] && i < vt[j].second)
	dp[i + vt[j].first] = true;
    }
  }
  
  for(int i = 20000; i >= 0; i--){
    if(dp[i]){
      cout << i << endl;
      break;
    }
  }
}
0