Submission #544635

#TimeUsernameProblemLanguageResultExecution timeMemory
544635pokmui9909앱 (KOI13_app)C++17
21 / 21
2 ms2772 KiB
#include <bits/stdc++.h> using namespace std; int D[105][10005]; int ar[105][2]; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int n, m; cin >> n >> m; int sum = 0; for(int i = 1; i <= n; i++) cin >> ar[i][0]; for(int i = 1; i <= n; i++) { cin >> ar[i][1]; sum += ar[i][1]; } for(int i = 1; i <= n; i++) { for(int j = 0; j <= sum; j++) { if(j - ar[i][1] < 0) D[i][j] = D[i - 1][j]; else D[i][j] = max(D[i - 1][j], D[i - 1][j - ar[i][1]] + ar[i][0]); } } int ans = 0; for(;D[n][ans] < m; ans++); cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...