結果
問題 | No.54 Happy Hallowe'en |
ユーザー | tnakao0123 |
提出日時 | 2016-03-04 16:11:55 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 225 ms / 5,000 ms |
コード長 | 1,252 bytes |
コンパイル時間 | 723 ms |
コンパイル使用メモリ | 86,300 KB |
実行使用メモリ | 100,764 KB |
最終ジャッジ日時 | 2024-04-23 16:43:38 |
合計ジャッジ時間 | 2,726 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 51 ms
30,908 KB |
testcase_05 | AC | 80 ms
39,040 KB |
testcase_06 | AC | 108 ms
52,096 KB |
testcase_07 | AC | 155 ms
72,512 KB |
testcase_08 | AC | 185 ms
85,524 KB |
testcase_09 | AC | 225 ms
100,764 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 199 ms
93,092 KB |
testcase_13 | AC | 218 ms
99,508 KB |
testcase_14 | AC | 2 ms
6,944 KB |
testcase_15 | AC | 1 ms
6,944 KB |
testcase_16 | AC | 3 ms
6,940 KB |
testcase_17 | AC | 2 ms
6,940 KB |
testcase_18 | AC | 2 ms
6,944 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; }