제출 #153904

#제출 시각아이디문제언어결과실행 시간메모리
153904mhy908만두 (JOI14_ho_t2)C++14
100 / 100
42 ms20140 KiB
#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) 메시지

2014_ho_t2.cpp: In function 'int main()':
2014_ho_t2.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
2014_ho_t2.cpp:21:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1; i<=n; i++)scanf("%d", &p[i]);
                            ~~~~~^~~~~~~~~~~~~
2014_ho_t2.cpp:24:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1; i<=m; i++)scanf("%d %d", &c[i], &e[i]);
                            ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...