結果

問題 No.54 Happy Hallowe'en
ユーザー nxterunxteru
提出日時 2018-06-18 22:52:17
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 52 ms / 5,000 ms
コード長 625 bytes
コンパイル時間 661 ms
コンパイル使用メモリ 70,300 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-13 06:57:54
合計ジャッジ時間 1,859 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

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(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