Submission #1161824

#TimeUsernameProblemLanguageResultExecution timeMemory
1161824CiprianKnapsack (NOI18_knapsack)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int dp[(int)1e5+5][(int)2005]; bool dp1[(int)1e5+5][(int)2005]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); int s,n; cin>>s>>n; vector<int>v(n+1),w(n+1),k(n+1); for(int i=1; i<=n; i++){ cin>>v[i]>>w[i]>>k[i]; }int mx=0; for(int j=0; j<=s; j++){ for(int i=1; i<=n; i++){ if(j>=w[i])dp[i][j]=max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]); mx=max(mx, dp[i][j]); } } cout<<mx<<endl; return 0; } #include <bits/stdc++.h> using namespace std; #define int long long int dp[(int)1e5+5][(int)2005]; bool dp1[(int)1e5+5][(int)2005]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); int s,n; cin>>s>>n; vector<int>v(n+1),w(n+1),k(n+1); for(int i=1; i<=n; i++){ cin>>v[i]>>w[i]>>k[i]; }int mx=0; for(int j=0; j<=s; j++){ for(int i=1; i<=n; i++){ if(j>=w[i])dp[i][j]=max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]); mx=max(mx, dp[i][j]); } } cout<<mx<<endl; return 0; }

Compilation message (stderr)

knapsack.cpp:30:5: error: redefinition of 'long long int dp [100005][2005]'
   30 | int dp[(int)1e5+5][(int)2005];
      |     ^~
knapsack.cpp:5:5: note: 'long long int dp [100005][2005]' previously declared here
    5 | int dp[(int)1e5+5][(int)2005];
      |     ^~
knapsack.cpp:31:6: error: redefinition of 'bool dp1 [100005][2005]'
   31 | bool dp1[(int)1e5+5][(int)2005];
      |      ^~~
knapsack.cpp:6:6: note: 'bool dp1 [100005][2005]' previously declared here
    6 | bool dp1[(int)1e5+5][(int)2005];
      |      ^~~
knapsack.cpp:32:9: error: redefinition of 'int32_t main()'
   32 | int32_t main()
      |         ^~~~
knapsack.cpp:7:9: note: 'int32_t main()' previously defined here
    7 | int32_t main()
      |         ^~~~