# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
39682 | 2018-01-17T06:59:04 Z | 14kg | 만두 팔기 (JOI14_manju) | C++11 | 1000 ms | 25660 KB |
#include <stdio.h> #include <algorithm> #define min2(x,y) (x<y?x:y) using namespace std; struct BOX { int cnt, value; } box[501]; int n, m, in[10001], p[10001]; int dp[501][10001]; bool check[501][10001]; int max2(int x, int y) { return x > y ? x : y; } int f(int x, int y) { if (x == 0 || y == 0) return 0; if (!check[x][y]) { int cnt = min2(y, box[x].cnt); dp[x][y] = max2(f(x - 1, y), f(x - 1, y - cnt) + p[y] - p[y - cnt] - box[x].value); } return dp[x][y]; } int main() { scanf("%d %d", &m, &n); for (int i = 1; i <= m; i++) scanf("%d", &in[i]); for (int i = 1; i <= n; i++) scanf("%d %d", &box[i].cnt, &box[i].value); sort(in + 1, in + m + 1); for (int i = 1; i <= m; i++) p[i] = p[i - 1] + in[i]; printf("%d", f(n, m)); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 25660 KB | Output is correct |
2 | Correct | 0 ms | 25660 KB | Output is correct |
3 | Correct | 0 ms | 25660 KB | Output is correct |
4 | Correct | 0 ms | 25660 KB | Output is correct |
5 | Correct | 0 ms | 25660 KB | Output is correct |
6 | Correct | 0 ms | 25660 KB | Output is correct |
7 | Correct | 0 ms | 25660 KB | Output is correct |
8 | Correct | 0 ms | 25660 KB | Output is correct |
9 | Correct | 0 ms | 25660 KB | Output is correct |
10 | Correct | 3 ms | 25660 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1000 ms | 25660 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 25660 KB | Output is correct |
2 | Execution timed out | 1000 ms | 25660 KB | Execution timed out |
3 | Halted | 0 ms | 0 KB | - |