Submission #635832

#TimeUsernameProblemLanguageResultExecution timeMemory
635832zeroesandonesKnapsack (NOI18_knapsack)C++17
12 / 100
1 ms320 KiB
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef long double ld; typedef vector<ll> vi; typedef pair<ll, ll> pi; #define FOR(i, j, k) for (ll i = j; i < (ll) k; ++i) #define FORD(i, j, k) for (ll i = j; i >= (ll) k; --i) #define nl "\n" #define all(x) (x).begin(), (x).end() #define sc second #define fr first #define pb push_back void solve() { ll s, n; cin >> s >> n; ll v, w, k; cin >> v >> w >> k; ll currW = w; ll ans = v; ll cnt = 1; while((currW + w) <= s && cnt < k) { ans += v; currW += w; ++cnt; } cout << ans << nl; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll t = 1; // cin >> t; while (t--) { solve(); } }
#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...