結果

問題 No.54 Happy Hallowe'en
ユーザー ss_koishiss_koishi
提出日時 2014-11-06 17:11:55
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 688 bytes
コンパイル時間 782 ms
コンパイル使用メモリ 73,164 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 01:38:35
合計ジャッジ時間 2,298 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 14 ms
4,380 KB
testcase_05 AC 23 ms
4,380 KB
testcase_06 AC 32 ms
4,380 KB
testcase_07 AC 48 ms
4,380 KB
testcase_08 AC 63 ms
4,376 KB
testcase_09 AC 82 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 81 ms
4,380 KB
testcase_13 AC 82 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 WA -
testcase_17 AC 2 ms
4,376 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());
  
  
  dp[0] = true; 
  for(int j = 0; j < n; j++){
    for(int i = vt[j].second - 1; i >= 0; 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