結果

問題 No.54 Happy Hallowe'en
ユーザー nxterunxteru
提出日時 2018-06-18 22:46:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 629 bytes
コンパイル時間 2,615 ms
コンパイル使用メモリ 69,568 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-13 06:57:28
合計ジャッジ時間 2,139 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
struct o{
  int v,t;
  bool operator <(o&q){
      return v+t<q.v+q.t;
  }
};
int n,ans;
o a[10005];
bool dp[10005];
int main(void){
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i].v>>a[i].t;
    sort(a,a+n);
    dp[0]=true;
    for(int i=0;i<n;i++){
        for(int j=a[i].t-1;j>=0;j--){
            if(dp[j]){
                if(dp[j]+a[i].v<=10000)dp[j+a[i].v]=true;
                else ans=max(ans,j+a[i].v);
            }
        }
    }
    for(int i=10000;i>=0;i--){
        if(dp[i]){
            cout<<max(ans,i)<<endl;
            return 0;
        }
    }
}
0