結果
問題 | No.54 Happy Hallowe'en |
ユーザー |
![]() |
提出日時 | 2018-06-18 22:52:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 55 ms / 5,000 ms |
コード長 | 625 bytes |
コンパイル時間 | 609 ms |
コンパイル使用メモリ | 70,456 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-30 17:05:58 |
合計ジャッジ時間 | 1,893 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#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; } } }