Submission #1336932

#TimeUsernameProblemLanguageResultExecution timeMemory
1336932Nipphitch만두 (JOI14_ho_t2)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
const int M=505;
const int N=5e6+5;

int n,m,c[M],e[M],p[N],dp1[N],dp2[M][N],ans;

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for(int i=1;i<=n;i++) cin >> p[i];
    sort(p+1,p+1+n,greater <int>());
    for(int i=1;i<=NN;i++) dp1[i]=dp1[i-1]+p[i];
    for(int i=0;i<=m;i++) for(int j=1;j<=NN;j++) dp2[i][j]=INT_MAX/2;
    for(int i=1;i<=m;i++){
        cin >> c[i] >> e[i];
        for(int j=NN;j>=1;j--){
            dp2[i][j]=dp2[i-1][j];
            if(j-c[i]<0) continue;
            dp2[i][j]=min(dp2[i][j],dp2[i-1][j-c[i]]+e[i]);
        }
    }
    for(int i=1;i<=NN;i++) ans=max(ans,dp1[i]-dp2[m][i]);
    //for(int i=0;i<=n*2;i++) cout << dp2[m][i] << " ";
    cout << ans;
}

Compilation message (stderr)

2014_ho_t2.cpp: In function 'int main()':
2014_ho_t2.cpp:15:20: error: 'NN' was not declared in this scope; did you mean 'N'?
   15 |     for(int i=1;i<=NN;i++) dp1[i]=dp1[i-1]+p[i];
      |                    ^~
      |                    N
2014_ho_t2.cpp:16:42: error: 'NN' was not declared in this scope; did you mean 'N'?
   16 |     for(int i=0;i<=m;i++) for(int j=1;j<=NN;j++) dp2[i][j]=INT_MAX/2;
      |                                          ^~
      |                                          N
2014_ho_t2.cpp:19:19: error: 'NN' was not declared in this scope; did you mean 'N'?
   19 |         for(int j=NN;j>=1;j--){
      |                   ^~
      |                   N
2014_ho_t2.cpp:25:20: error: 'NN' was not declared in this scope; did you mean 'N'?
   25 |     for(int i=1;i<=NN;i++) ans=max(ans,dp1[i]-dp2[m][i]);
      |                    ^~
      |                    N