# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
683383 | vjudge1 | Knapsack (NOI18_knapsack) | C++17 | 1083 ms | 1332 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ull unsigned long long
#define ed '\n'
#define pb push_back
#define int long long
#define ii pair<int,int>
#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define fi first
#define se second
using namespace __gnu_pbds;
using namespace std;
int dp[2005];
void solve() {
int s, n;
cin >> s >> n;
while(n--) {
int v, w, cnt;
cin >> v >> w >> cnt;
int tmp = 1;
while(cnt) {
int cv = v * min(tmp, cnt);
int cw = w * min(tmp, cnt);
for(int i = s; i >= cw; --i) {
dp[i] = max(dp[i], dp[i - cw] + cv);
}
cnt -= min(tmp, cnt);
tmp *= 2;
}
}
cout << dp[s];
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
if (fopen("cf.inp", "r")) {
freopen("cf.inp", "r", stdin);
//freopen("cf.inp", "w", stdout);
}
solve();
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... |