# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
18568 |
2016-02-09T09:36:59 Z |
choyi0521 |
만두 팔기 (JOI14_manju) |
C++14 |
|
20 ms |
1200 KB |
#include<stdio.h>
#include<algorithm>
using namespace std;
const int MAX_M = 1e4;
int m, n,a[10000],dp[MAX_M*2+1],res;
int main() {
scanf("%d %d", &m, &n);
for (int i = 0; i < m; i++) scanf("%d", &a[i]);
sort(a, a + m);
fill(dp + 1, dp + MAX_M*2+1,1e9);
for (int i = 0; i < n; i++) {
int x, y;
scanf("%d %d", &x, &y);
for (int j = MAX_M * 2; j >= x; j--)
dp[j] = min(dp[j], dp[j - x] + y);
}
for (int i = MAX_M * 2; i; i--) dp[i - 1] = min(dp[i - 1], dp[i]);
int s = 0;
for (int i = m - 1; i >= 0; i--) {
s += a[i];
res = max(res, s - dp[m-i]);
}
printf("%d", res);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1200 KB |
Output is correct |
2 |
Correct |
0 ms |
1200 KB |
Output is correct |
3 |
Correct |
3 ms |
1200 KB |
Output is correct |
4 |
Correct |
0 ms |
1200 KB |
Output is correct |
5 |
Correct |
0 ms |
1200 KB |
Output is correct |
6 |
Correct |
0 ms |
1200 KB |
Output is correct |
7 |
Correct |
0 ms |
1200 KB |
Output is correct |
8 |
Correct |
0 ms |
1200 KB |
Output is correct |
9 |
Correct |
0 ms |
1200 KB |
Output is correct |
10 |
Correct |
0 ms |
1200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
1200 KB |
Output is correct |
2 |
Correct |
19 ms |
1200 KB |
Output is correct |
3 |
Correct |
19 ms |
1200 KB |
Output is correct |
4 |
Correct |
19 ms |
1200 KB |
Output is correct |
5 |
Correct |
19 ms |
1200 KB |
Output is correct |
6 |
Correct |
17 ms |
1200 KB |
Output is correct |
7 |
Correct |
14 ms |
1200 KB |
Output is correct |
8 |
Correct |
19 ms |
1200 KB |
Output is correct |
9 |
Correct |
17 ms |
1200 KB |
Output is correct |
10 |
Correct |
18 ms |
1200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
1200 KB |
Output is correct |
2 |
Correct |
14 ms |
1200 KB |
Output is correct |
3 |
Correct |
11 ms |
1200 KB |
Output is correct |
4 |
Correct |
14 ms |
1200 KB |
Output is correct |
5 |
Correct |
15 ms |
1200 KB |
Output is correct |
6 |
Correct |
15 ms |
1200 KB |
Output is correct |
7 |
Correct |
17 ms |
1200 KB |
Output is correct |
8 |
Correct |
18 ms |
1200 KB |
Output is correct |
9 |
Correct |
20 ms |
1200 KB |
Output is correct |
10 |
Correct |
18 ms |
1200 KB |
Output is correct |