結果
| 問題 | No.54 Happy Hallowe'en |
| コンテスト | |
| ユーザー |
koyopro
|
| 提出日時 | 2015-09-30 13:44:09 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 33 ms / 5,000 ms |
| コード長 | 684 bytes |
| 記録 | |
| コンパイル時間 | 1,184 ms |
| コンパイル使用メモリ | 186,372 KB |
| 実行使用メモリ | 7,972 KB |
| 最終ジャッジ日時 | 2026-05-05 04:52:58 |
| 合計ジャッジ時間 | 2,308 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}
koyopro