| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1027413 | Robert_junior | Knapsack (NOI18_knapsack) | C++17 | 1061 ms | 1372 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#include <iostream>
#include <vector>
using namespace std;
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz size()
#define ins insert
void solve(){
int m, n;
cin>>m>>n;
vector<int>dp(m + 1);
vector<int>dp1(m + 1);
int a, b, c;
for(int i = 1; i <= n; i++){
cin>>a>>b>>c;
for(int j = 0; j <= m; j++){
dp1[j] = dp[j];
}
for(int j = 0; j <= m; j++){
for(int k = 1; k <= c && j + b * k <= m; k++){
dp[j + b * k] = max(dp[j + b * k], dp1[j] + k * a);
}
}
}
int mx = 0;
for(int i = 0; i <= m; i++) mx = max(mx, dp[i]);
cout<<mx<<'\n';
}
main(){
//freopen("circlecross.in", "r", stdin);
//freopen("circlecross.out", "w", stdout);
ios_base :: sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
//cin>>t;
while(t--){
solve();
}
}
//3 2 4 4 1 3 2 1컴파일 시 표준 에러 (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... | ||||
