Submission #55136

# Submission time Handle Problem Language Result Execution time Memory
55136 2018-07-06T06:03:03 Z 노영훈(#1526) None (JOI14_ho_t2) C++11
0 / 100
11 ms 696 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+n+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 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 5 ms 692 KB Output is correct
4 Correct 4 ms 692 KB Output is correct
5 Correct 4 ms 692 KB Output is correct
6 Correct 2 ms 692 KB Output is correct
7 Incorrect 2 ms 692 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 696 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 5 ms 692 KB Output is correct
4 Correct 4 ms 692 KB Output is correct
5 Correct 4 ms 692 KB Output is correct
6 Correct 2 ms 692 KB Output is correct
7 Incorrect 2 ms 692 KB Output isn't correct
8 Halted 0 ms 0 KB -