# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
941691 | 2024-03-09T09:50:27 Z | yophis | Knapsack (NOI18_knapsack) | C++17 | 1000 ms | 33980 KB |
#include <iostream> #include <vector> #include <algorithm> #include <set> #include <cmath> #include <cstdio> #include <map> #include <stack> #include <numeric> #include <queue> #include <climits> using namespace std; using ll = long long; using str = string; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vb = vector<bool>; #define all(x) begin(x), end(x) #define lb lower_bound #define ub upper_bound #define pb push_back #define FOR(i,a,b) for (int i = (a); i < (b); ++i) const int INF = 1e9; void setIO(string filename = "") { ios_base::sync_with_stdio(false); cin.tie(0); if (filename.size()) { freopen((filename+".in").c_str(), "r", stdin); freopen((filename+".out").c_str(), "w", stdout); } } // ===================================== int n,s; int main() { setIO(); cin >> s >> n; vector<pii> v; FOR (i, 0, n) { int val, weight, cnt; cin>>val>>weight>>cnt; FOR (j, 0, cnt) v.pb({val, weight}); } vl dp(s+1); for (auto &[val, weight]: v) { for (int i=s;i>=0;i--) { ll left = i - weight; if (left >= 0) { dp[i] = max(dp[i], dp[left] + val); } } } cout << dp[s] << '\n'; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1051 ms | 33980 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 452 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 452 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 344 KB | Output is correct |
11 | Correct | 1 ms | 500 KB | Output is correct |
12 | Correct | 2 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1051 ms | 33980 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1051 ms | 33980 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |