# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
527976 | juankipedia | Knapsack (NOI18_knapsack) | C++14 | 3 ms | 332 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
# include <bits/stdc++.h>
using namespace std;
/*************************************************************************************/
# define endl "\n"
# define io_boost std::ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
typedef unsigned long long int ulli;
typedef long long int lli;
/*************************************JUANKIPEDIA*************************************/
const int MAXN = 100005;
lli N, S, V[MAXN], W[MAXN], K[MAXN];
int main(){
io_boost;
cin >> S >> N;
for(lli i = 0; i < N; i++) cin >> V[i] >> W[i] >> K[i];
vector<lli> dp(S + 5, 0);
for(lli i = 0; i < N; i++){
vector<lli> DP;
DP = dp;
for(lli j = K[i]; j >= 1; j--){
lli w = W[i] * j;
if(w > S) break;
for(lli k = S - w; k >= 0; k--){
DP[k + w] = max(DP[k + w], dp[k] + (V[i] * j));
}
}
for(int j = 0; j < dp.size(); j++) dp[j] = max(dp[j], DP[j]);
}
lli ans = 0;
for(int i = 0; i <= S; i++){
ans = max(ans, dp[i]);
if(ans == 5500) cout << " ===== " << i << endl;
}
cout << ans << endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |