Submission #1172315

#TimeUsernameProblemLanguageResultExecution timeMemory
1172315dbekarysKnapsack (NOI18_knapsack)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int dp[1e5][1e5]; signed main() { ios_base::sync_with_stdio(0); cin.tie(); int m,n; cin>> m>>n; int a[n+1],b[n+1]; vector<int>v1,v2; v1.push_back(0); v2.push_back(0); for(int i=1,c;i<=n;i++){ cin>> b[i]>>a[i]>>c; for(int k=0;k<c;k++){ v1.push_back(a[i]),v2.push_back(b[i]); } } for(int i=1;i<=v1.size();i++){ for(int j=1;j<=m;j++){ dp[i][j]=dp[i-1][j]; if(v1[i]<=j){ dp[i][j]=max(dp[i][j],dp[i-1][j-v1[i]]+v2[i]); } } } cout<< dp[v1.size()][m]; }

Compilation message (stderr)

knapsack.cpp:4:13: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    4 | int dp[1e5][1e5];
      |             ^~~
knapsack.cpp:4:13: error: could not convert '1.0e+5' from 'double' to 'long unsigned int'
    4 | int dp[1e5][1e5];
      |             ^~~
      |             |
      |             double
knapsack.cpp:4:13: error: size of array 'dp' has non-integral type 'double'
knapsack.cpp:4:8: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    4 | int dp[1e5][1e5];
      |        ^~~
knapsack.cpp:4:8: error: could not convert '1.0e+5' from 'double' to 'long unsigned int'
    4 | int dp[1e5][1e5];
      |        ^~~
      |        |
      |        double
knapsack.cpp:4:8: error: size of array 'dp' has non-integral type 'double'