Submission #70469

# Submission time Handle Problem Language Result Execution time Memory
70469 2018-08-23T02:28:36 Z Diuven None (JOI14_ho_t2) C++14
100 / 100
22 ms 1916 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=500010, inf=2e9;

int n, m;
int P[10010];
int S[10010];
int E[510];
int C[510];
int D[10010];

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>m>>n;
    for(int i=1; i<=m; i++) cin>>P[i];
    for(int i=1; i<=n; i++) cin>>C[i]>>E[i];
    sort(P+1, P+m+1, greater<int>());
    for(int i=1; i<=m; i++) S[i]=S[i-1]+P[i];
    for(int i=1; i<=m; i++) D[i]=inf;
    D[0]=0;
    for(int i=1; i<=n; i++){
        for(int j=m; j>=0; j--)
            D[min(j+C[i], m)]=min(D[min(j+C[i], m)], D[j]+E[i]);
    }
    int ans=0;
    for(int i=1; i<=m; i++) ans=max(ans, S[i]-D[i]);
    cout<<ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 4 ms 732 KB Output is correct
4 Correct 4 ms 896 KB Output is correct
5 Correct 5 ms 896 KB Output is correct
6 Correct 3 ms 896 KB Output is correct
7 Correct 2 ms 896 KB Output is correct
8 Correct 2 ms 896 KB Output is correct
9 Correct 4 ms 920 KB Output is correct
10 Correct 6 ms 1028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1076 KB Output is correct
2 Correct 13 ms 1152 KB Output is correct
3 Correct 13 ms 1192 KB Output is correct
4 Correct 13 ms 1236 KB Output is correct
5 Correct 11 ms 1268 KB Output is correct
6 Correct 3 ms 1268 KB Output is correct
7 Correct 9 ms 1308 KB Output is correct
8 Correct 13 ms 1340 KB Output is correct
9 Correct 5 ms 1364 KB Output is correct
10 Correct 12 ms 1452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 4 ms 732 KB Output is correct
4 Correct 4 ms 896 KB Output is correct
5 Correct 5 ms 896 KB Output is correct
6 Correct 3 ms 896 KB Output is correct
7 Correct 2 ms 896 KB Output is correct
8 Correct 2 ms 896 KB Output is correct
9 Correct 4 ms 920 KB Output is correct
10 Correct 6 ms 1028 KB Output is correct
11 Correct 15 ms 1076 KB Output is correct
12 Correct 13 ms 1152 KB Output is correct
13 Correct 13 ms 1192 KB Output is correct
14 Correct 13 ms 1236 KB Output is correct
15 Correct 11 ms 1268 KB Output is correct
16 Correct 3 ms 1268 KB Output is correct
17 Correct 9 ms 1308 KB Output is correct
18 Correct 13 ms 1340 KB Output is correct
19 Correct 5 ms 1364 KB Output is correct
20 Correct 12 ms 1452 KB Output is correct
21 Correct 18 ms 1484 KB Output is correct
22 Correct 14 ms 1484 KB Output is correct
23 Correct 17 ms 1608 KB Output is correct
24 Correct 15 ms 1640 KB Output is correct
25 Correct 19 ms 1700 KB Output is correct
26 Correct 22 ms 1780 KB Output is correct
27 Correct 6 ms 1780 KB Output is correct
28 Correct 12 ms 1828 KB Output is correct
29 Correct 13 ms 1868 KB Output is correct
30 Correct 12 ms 1916 KB Output is correct