제출 #1064295

#제출 시각아이디문제언어결과실행 시간메모리
1064295vjudge1Knapsack (NOI18_knapsack)C++17
0 / 100
3 ms1624 KiB
#include<bits/stdc++.h> #define int long long #define endl '\n' using namespace std; int n,m; int a[105]; int b[105]; int c[105]; int dp[105][100005]; int res[105]; main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); // freopen("main.inp", "r", stdin); // freopen("main.out", "w", stdout); cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> a[i] >> b[i] >> c[i]; } for (int i = 1; i <= n; i++) { dp[i][0] = 0; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { dp[i][j] = dp[i-1][j]; for (int k = 0; k <= min(c[i],j/a[i]); k++) { if (dp[i-1][j-k*a[i]]+b[i]*k > dp[i][j]) { //trace[i][j] = k; dp[i][j] = dp[i-1][j-k*a[i]]+b[i]*k; } } } } cout << dp[n][m]; }

컴파일 시 표준 에러 (stderr) 메시지

knapsack.cpp:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...