# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
153904 | mhy908 | 만두 (JOI14_ho_t2) | C++14 | 42 ms | 20140 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define llinf 8987654321987654321
#define inf 1987654321
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
int n, m;
int p[10010], sum[10010];
int c[510], e[510];
int dp[510][10010];
int fin[10010];
int ans;
int main()
{
scanf("%d %d", &n, &m);
for(int i=1; i<=n; i++)scanf("%d", &p[i]);
sort(p+1, p+n+1, greater<int>());
for(int i=1; i<=n; i++)sum[i]=p[i]+sum[i-1];
for(int i=1; i<=m; i++)scanf("%d %d", &c[i], &e[i]);
for(int i=1; i<=10000; i++)dp[0][i]=inf;
for(int i=1; i<=m; i++){
for(int j=0; j<c[i]; j++)dp[i][j]=dp[i-1][j];
for(int j=0; j+c[i]<=10000; j++)dp[i][j+c[i]]=min(dp[i-1][j+c[i]], dp[i-1][j]+e[i]);
for(int j=9999; j>=0; j--)dp[i][j]=min(dp[i][j], dp[i][j+1]);
}
for(int i=1; i<=n; i++)ans=max(ans, sum[i]-dp[m][i]);
printf("%d", ans);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |