結果
問題 | No.54 Happy Hallowe'en |
ユーザー |
![]() |
提出日時 | 2015-09-30 13:44:09 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 41 ms / 5,000 ms |
コード長 | 684 bytes |
コンパイル時間 | 1,606 ms |
コンパイル使用メモリ | 163,812 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-15 17:13:40 |
合計ジャッジ時間 | 2,272 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include "bits/stdc++.h" using namespace std; #define REP(i, n) for(int i=0; i<(n); i++) #define RREP(i, n) for(int i=(n-1); i>=0; i--) #define ALL(a) (a).begin(),(a).end() struct home { int v, t; }; int N; vector<home> homes; bool comp(home a, home b) { return a.t + a.v < b.t + b.v; } signed main() { cin >> N; homes.resize(N); REP(i,N) cin >> homes[i].v >> homes[i].t; bool dp[20000] = {0}; dp[0] = true; sort(ALL(homes), comp); REP(i,N) { RREP(j,homes[i].t) { dp[j+homes[i].v] |= dp[j]; } } RREP(i,20000) { if (dp[i]) { cout << i << endl; break; } } return 0; }