Submission #153904

# Submission time Handle Problem Language Result Execution time Memory
153904 2019-09-17T11:48:25 Z mhy908 None (JOI14_ho_t2) C++14
100 / 100
42 ms 20140 KB
#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);
}

Compilation message

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 time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 5 ms 888 KB Output is correct
4 Correct 4 ms 888 KB Output is correct
5 Correct 4 ms 888 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 3 ms 760 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
9 Correct 5 ms 920 KB Output is correct
10 Correct 5 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 20040 KB Output is correct
2 Correct 41 ms 20088 KB Output is correct
3 Correct 41 ms 20088 KB Output is correct
4 Correct 41 ms 20088 KB Output is correct
5 Correct 40 ms 20088 KB Output is correct
6 Correct 39 ms 19960 KB Output is correct
7 Correct 33 ms 16120 KB Output is correct
8 Correct 42 ms 20088 KB Output is correct
9 Correct 39 ms 19956 KB Output is correct
10 Correct 40 ms 20088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 5 ms 888 KB Output is correct
4 Correct 4 ms 888 KB Output is correct
5 Correct 4 ms 888 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 3 ms 760 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
9 Correct 5 ms 920 KB Output is correct
10 Correct 5 ms 888 KB Output is correct
11 Correct 41 ms 20040 KB Output is correct
12 Correct 41 ms 20088 KB Output is correct
13 Correct 41 ms 20088 KB Output is correct
14 Correct 41 ms 20088 KB Output is correct
15 Correct 40 ms 20088 KB Output is correct
16 Correct 39 ms 19960 KB Output is correct
17 Correct 33 ms 16120 KB Output is correct
18 Correct 42 ms 20088 KB Output is correct
19 Correct 39 ms 19956 KB Output is correct
20 Correct 40 ms 20088 KB Output is correct
21 Correct 38 ms 20088 KB Output is correct
22 Correct 39 ms 20140 KB Output is correct
23 Correct 39 ms 20088 KB Output is correct
24 Correct 39 ms 20024 KB Output is correct
25 Correct 39 ms 20024 KB Output is correct
26 Correct 39 ms 20088 KB Output is correct
27 Correct 42 ms 19960 KB Output is correct
28 Correct 41 ms 20088 KB Output is correct
29 Correct 41 ms 20088 KB Output is correct
30 Correct 39 ms 19644 KB Output is correct