답안 #95418

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
95418 2019-02-01T03:58:40 Z easrui 만두 (JOI14_ho_t2) C++14
0 / 100
4 ms 1272 KB
#include <bits/stdc++.h>
using namespace std;
const int MM = 1e4+5;
const int MN = 505;
int M,N,P[MM],S[MM],C[MN],E[MN],ans,res;
int D[10*MM][2];

int main()
{
    freopen("input.txt","r",stdin);
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> M >> N;
    for(int i=1; i<=M; i++)
        cin >> P[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<=1e5; i++) D[i][0] = D[i][1] = 1e9;
    for(int i=1; i<=N; i++) cin >> C[i] >> E[i];
    for(int i=1; i<=N; i++){
        for(int j=1e5; j>=C[i]; j--){
            D[j][i%2] = min(D[j][(i+1)%2],D[j-C[i]][(i+1)%2] + E[i]);
            if(j!=1e5) D[j][i%2] = min(D[j][i%2],D[j+1][i%2]);
        }
    }
    //cout << D[2][N%2];
    for(int i=0; i<=M; i++){
        ans = max(ans,S[i]-D[i][N%2]);
    }
    cout << ans;
}

Compilation message

2014_ho_t2.cpp: In function 'int main()':
2014_ho_t2.cpp:10:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("input.txt","r",stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1144 KB Output is correct
2 Incorrect 4 ms 1272 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1272 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1144 KB Output is correct
2 Incorrect 4 ms 1272 KB Output isn't correct
3 Halted 0 ms 0 KB -