| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 705989 | lukameladze | Knapsack (NOI18_knapsack) | C++14 | 2 ms | 468 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
# include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define int long long
#define pii pair <int, int>
#define pb push_back
const int N = 1e6 + 5;
int t,n,a[N],v[N],w[N],k[N],s,dp[N];
main() {
std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>s>>n;
vector <pii> vec;
vec.pb({0, 0});
for (int i = 1; i <= n; i++) {
cin>>v[i]>>w[i]>>k[i];
for (int j = 0; j <= 31; j++) {
if (k[i] >= (1<<j)) {
int x = (1<<j);
k[i] -= x;
if (x * w[i] <= s)
vec.pb({x * v[i], x * w[i]});
}
}
if (k[i] && w[i] * k[i] <= s) vec.pb({k[i] * v[i], k[i] * w[i]});
}
int ans = 0;
for (int i = 1; i < vec.size(); i++) {
for (int j = s; j >= vec[i].s; j--) {
dp[j] = max(dp[j], dp[j - vec[i].s] + vec[i].f);
ans = max(ans, dp[j]);
}
}
cout<<ans<<"\n";
}컴파일 시 표준 에러 (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... | ||||
