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