結果
問題 | No.54 Happy Hallowe'en |
ユーザー | tnakao0123 |
提出日時 | 2016-03-04 16:11:55 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 180 ms / 5,000 ms |
コード長 | 1,252 bytes |
コンパイル時間 | 578 ms |
コンパイル使用メモリ | 85,476 KB |
実行使用メモリ | 100,284 KB |
最終ジャッジ日時 | 2023-08-05 20:09:34 |
合計ジャッジ時間 | 2,379 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 41 ms
31,180 KB |
testcase_05 | AC | 61 ms
43,488 KB |
testcase_06 | AC | 82 ms
55,832 KB |
testcase_07 | AC | 111 ms
72,296 KB |
testcase_08 | AC | 145 ms
84,628 KB |
testcase_09 | AC | 180 ms
100,284 KB |
testcase_10 | AC | 2 ms
4,376 KB |
testcase_11 | AC | 1 ms
4,376 KB |
testcase_12 | AC | 174 ms
100,008 KB |
testcase_13 | AC | 179 ms
100,044 KB |
testcase_14 | AC | 2 ms
4,376 KB |
testcase_15 | AC | 1 ms
4,376 KB |
testcase_16 | AC | 2 ms
4,376 KB |
testcase_17 | AC | 2 ms
4,376 KB |
testcase_18 | AC | 1 ms
4,376 KB |
ソースコード
/* -*- coding: utf-8 -*- * * 54.cc: No.54 Happy Hallowe'en - yukicoder */ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<string> #include<vector> #include<map> #include<set> #include<stack> #include<list> #include<queue> #include<deque> #include<algorithm> #include<numeric> #include<utility> #include<complex> #include<functional> using namespace std; /* constant */ const int MAX_N = 10000; const int MAX_T = 10000; /* typedef */ struct VT { int v, t, sum; VT() {} VT(int _v, int _t): v(_v), t(_t) { sum = v + t; } bool operator<(const VT &vt) const { return sum < vt.sum; } }; /* global variables */ VT vts[MAX_N]; bool dp[MAX_N + 1][MAX_T]; /* subroutines */ /* main */ int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int vi, ti; cin >> vi >> ti; vts[i] = VT(vi, ti); } sort(vts, vts + n); dp[0][0] = true; int ans = -1; for (int i = 0; i < n; i++) { int &vi = vts[i].v, &ti = vts[i].t; for (int j = 0; j < MAX_T; j++) if (dp[i][j]) { dp[i + 1][j] = true; if (j < ti) { int j0 = j + vi; if (ans < j0) ans = j0; if (j0 < MAX_T) dp[i + 1][j0] = true; } } } printf("%d\n", ans); return 0; }