# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
55134 | 2018-07-06T05:58:25 Z | 강태규(#1525) | 만두 (JOI14_ho_t2) | C++11 | 39 ms | 20392 KB |
#include <iostream> #include <algorithm> #include <vector> #include <queue> #include <deque> #include <set> #include <map> #include <unordered_map> #include <functional> #include <cstring> #include <cmath> #include <ctime> #include <cstdlib> using namespace std; typedef long long llong; typedef long double ld; typedef pair<int, int> pii; typedef pair<llong, llong> pll; int m, n; const int inf = 2e8; int mandu[10001]; int cugi[501]; int gaguk[501]; int dp[501][10001]; int main() { scanf("%d%d", &m, &n); for (int i = 1; i <= m; ++i) { scanf("%d", mandu + i); } for (int i = 1; i <= n; ++i) { scanf("%d%d", cugi + i, gaguk + i); } sort(mandu + 1, mandu + (m + 1), greater<int>()); for (int i = 1; i <= m; ++i) { mandu[i] += mandu[i - 1]; } for (int i = 1; i <= m; ++i) dp[0][i] = inf; for (int i = 1; i <= n; ++i) { for (int j = 0; j <= m; ++j) dp[i][j] = dp[i - 1][j]; for (int j = 0; j <= m; ++j) { int cug = min(j + cugi[i], m); dp[i][cug] = min(dp[i][cug], dp[i - 1][j] + gaguk[i]); } } int ans = 0; for (int i = 0; i <= m; ++i) { ans = max(ans, mandu[i] - dp[n][i]); } printf("%d\n", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 6 ms | 944 KB | Output is correct |
4 | Correct | 4 ms | 944 KB | Output is correct |
5 | Correct | 3 ms | 944 KB | Output is correct |
6 | Correct | 2 ms | 944 KB | Output is correct |
7 | Correct | 2 ms | 944 KB | Output is correct |
8 | Correct | 2 ms | 944 KB | Output is correct |
9 | Correct | 4 ms | 992 KB | Output is correct |
10 | Correct | 5 ms | 1032 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 20204 KB | Output is correct |
2 | Correct | 27 ms | 20204 KB | Output is correct |
3 | Correct | 27 ms | 20204 KB | Output is correct |
4 | Correct | 27 ms | 20300 KB | Output is correct |
5 | Correct | 27 ms | 20300 KB | Output is correct |
6 | Correct | 6 ms | 20300 KB | Output is correct |
7 | Correct | 23 ms | 20300 KB | Output is correct |
8 | Correct | 26 ms | 20312 KB | Output is correct |
9 | Correct | 6 ms | 20312 KB | Output is correct |
10 | Correct | 27 ms | 20312 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 6 ms | 944 KB | Output is correct |
4 | Correct | 4 ms | 944 KB | Output is correct |
5 | Correct | 3 ms | 944 KB | Output is correct |
6 | Correct | 2 ms | 944 KB | Output is correct |
7 | Correct | 2 ms | 944 KB | Output is correct |
8 | Correct | 2 ms | 944 KB | Output is correct |
9 | Correct | 4 ms | 992 KB | Output is correct |
10 | Correct | 5 ms | 1032 KB | Output is correct |
11 | Correct | 27 ms | 20204 KB | Output is correct |
12 | Correct | 27 ms | 20204 KB | Output is correct |
13 | Correct | 27 ms | 20204 KB | Output is correct |
14 | Correct | 27 ms | 20300 KB | Output is correct |
15 | Correct | 27 ms | 20300 KB | Output is correct |
16 | Correct | 6 ms | 20300 KB | Output is correct |
17 | Correct | 23 ms | 20300 KB | Output is correct |
18 | Correct | 26 ms | 20312 KB | Output is correct |
19 | Correct | 6 ms | 20312 KB | Output is correct |
20 | Correct | 27 ms | 20312 KB | Output is correct |
21 | Correct | 35 ms | 20312 KB | Output is correct |
22 | Correct | 33 ms | 20392 KB | Output is correct |
23 | Correct | 30 ms | 20392 KB | Output is correct |
24 | Correct | 31 ms | 20392 KB | Output is correct |
25 | Correct | 39 ms | 20392 KB | Output is correct |
26 | Correct | 30 ms | 20392 KB | Output is correct |
27 | Correct | 9 ms | 20392 KB | Output is correct |
28 | Correct | 28 ms | 20392 KB | Output is correct |
29 | Correct | 37 ms | 20392 KB | Output is correct |
30 | Correct | 28 ms | 20392 KB | Output is correct |