結果

問題 No.54 Happy Hallowe'en
ユーザー ss_koishi
提出日時 2014-11-06 17:11:55
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 688 bytes
コンパイル時間 880 ms
コンパイル使用メモリ 72,052 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-31 06:19:34
合計ジャッジ時間 1,868 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 WA * 1
権限があれば一括ダウンロードができます

ソースコード

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