anonymous ナップサック問題書き直し
No License C++
2019年05月20日
Copy Clone
#include <iostream>
#include <algorithm>
using namespace std;

const int n=6, W=8;
const int w[n] = {2,1,3,2,1,5}, v[n]={3,2,6,1,3,85};

int dp[10][10];

int rec(int i, int cap) {
    if (dp[i][cap] != -1) {
        return dp[i][cap];
    }

    int res;
    if (i == n) {
        res = 0;
    } else if (cap < w[i]) {
        res = rec(i + 1, cap);
    } else {
        res = max(
            rec(i + 1, cap),
            rec(i + 1, cap - w[i]) + v[i]
        );
    }
    return dp[i][cap] = res;
}

int main() {
    memset(dp, -1, sizeof(dp));
    cout << rec(0, W) << endl;
}
#include <iostream>
#include <algorithm>
using namespace std;

const int n=6, W=8;
const int w[n] = {2,1,3,2,1,5}, v[n]={3,2,6,1,3,85};

int dp[10][10];

int rec(int i, int cap) {
    if (dp[i][cap] != -1) {
        return dp[i][cap];
    }

    int res;
    if (i == n) {
        res = 0;
    } else if (cap < w[i]) {
        res = rec(i + 1, cap);
    } else {
        res = max(
            rec(i + 1, cap),
            rec(i + 1, cap - w[i]) + v[i]
        );
    }
    return dp[i][cap] = res;
}

int main() {
    memset(dp, -1, sizeof(dp));
    cout << rec(0, W) << endl;
}
anonymous
Anonymous
2019年05月21日
メモ化するやつね
Bot
Bot
2019年05月25日
#include <iostream> #include <algorithm> using namespace std; const int n=6, W=8; const int w[n] = {2,1,3,2,1,5}, v[n]={3,2,6,1,3,85}; int dp[10][10]; int rec(int i, int cap) { if (dp[i][cap] != -1) { return dp[i][cap]; } int res; if (i == n) { res = 0; } else if (cap < w[i]) { res = rec(i + 1, cap); } else { res = max( rec(i + 1, cap), rec(i + 1, cap - w[i]) + v[i] ); } return dp[i][cap] = res; } int main() { memset(dp, -1, sizeof(dp)); cout << rec(0, W) << endl; }
Bot
Bot
2019年05月26日
#include <iostream> #include <algorithm> using namespace std; const int n=6, W=8; const int w[n] = {2,1,3,2,1,5}, v[n]={3,2,6,1,3,85}; int dp[10][10]; int rec(int i, int cap) { if (dp[i][cap] != -1) { return dp[i][cap]; } int res; if (i == n) { res = 0; } else if (cap < w[i]) { res = rec(i + 1, cap); } else { res = max( rec(i + 1, cap), rec(i + 1, cap - w[i]) + v[i] ); } return dp[i][cap] = res; } int main() { memset(dp, -1, sizeof(dp)); cout << rec(0, W) << endl; }
anonymous
Anonymous
2019年06月01日
コメントテスト
anonymous
Anonymous
2019年06月08日
コメント
anonymous
Anonymous
2021年05月10日
Medicament prescribing information. What side effects? <a href="https://prednisone4u.top">buying generic prednisone tablets</a> in Canada. Best what you want to know about meds. Read now.
anonymous
Anonymous
2022年03月27日
price of college essay service <a href="https://englishessayblog.com/">pay for my research paper</a> communication theory essay writing service
anonymous
Anonymous
2021年05月19日
<a href="http://writemypaperkfd.com/">http://writemypaperkfd.com/</a>
anonymous
Anonymous
2021年05月20日
<a href="https://essaywriterserv.net/">https://essaywriterserv.net/</a>
anonymous
Anonymous
2021年06月16日
over the counter viagra <a href="https://luzviagra.com/">sildenafil citrate</a> viagra walmart
anonymous
Anonymous
2021年06月16日
sildenafil 25 mg <a href="https://lobviagra.net/">canadian pharmacy viagra 50 mg</a> sildenafil revatio
anonymous
Anonymous
2021年06月18日
cialis discount card <a href="https://cialistadalafillove.com/">cialis online canada</a> cialis without a doctor prescription canada
anonymous
Anonymous
2021年06月18日
online pharmacy viagra <a href="https://viagrasildenafillife.com/">200 milligram viagra</a> natural viagra
anonymous
Anonymous
2021年06月20日
Medication information leaflet. Long-Term Effects. <a href="https://trazodone4u.top">cheap viagra no prescription</a> in Canada Actual trends of medicament. Read information here.
anonymous
Anonymous
2021年06月20日
viagra from india <a href="https://sildenafilloveme.com/">where to buy viagra</a> itsoktocry viagra
anonymous
Anonymous
2021年06月21日
Drug information sheet. Brand names. <a href="https://cymbalta4m.top">get generic cymbalta</a> in the USA Best about drugs. Get information here.
anonymous
Anonymous
2021年06月22日
cialis dosage 40 mg <a href="https://toptadalafilmos.com/">cialis</a> cialis effects
anonymous
Anonymous
2021年06月22日
taking viagra for fun <a href="https://viagrakormes.com/">viagra otc</a> where to buy female viagra
anonymous
Anonymous
2021年06月24日
what is the difference between viagra and cialis <a href="https://cialislostik.com/">tadalafil canada</a> lowest price cialis
anonymous
Anonymous
2021年06月24日
cialis for sale <a href="https://cialiskira.net/">viagra and cialis together</a> is cialis safe
anonymous
Anonymous
2021年06月25日
viagra sildenafil <a href="https://viagra4m.top/">order viagra online</a> sildenafil online canada
anonymous
Anonymous
2021年06月23日
Drug information leaflet. Short-Term Effects. <a href="https://lyricafor.top">can i order cheap pregabalin online</a> in US Actual information about medicine. Get now.
anonymous
Anonymous
2021年06月24日
<a href="https://raznie-poleznosti.ru/">raznie-poleznosti.ru</a>
anonymous
Anonymous
2021年06月23日
Drugs information leaflet. Short-Term Effects. <a href="https://lyricainfo.top">buying cheap pregabalin without prescription</a> in Canada Best what you want to know about medication. Read information now.
anonymous
Anonymous
2021年06月23日
Drug prescribing information. Cautions. <a href="https://lyricainfo.top">order lyrica without insurance</a> in the USA All what you want to know about medication. Get here.
anonymous
Anonymous
2021年06月23日
<a href="https://viagra4m.top">viagra4m</a>
anonymous
Anonymous
2021年06月25日
contre indication cialis <a href="https://franctadalafil.com/">cialis sans ordonnance paris</a> cialis female
anonymous
Anonymous
2021年06月25日
sildenafil <a href="https://viagrafrancemy.com/">sildenafil 100mg prix</a> pasteque et citron viagra
anonymous
Anonymous
2021年06月27日
Исследование от врачей и экспертов о COVID-19, на авторитетном интернет-издании Коронавирус-Контроль со ссылками на официальные и государственные источники WHO - https://coronavirus-control.ru/kakie-lekarstva-nelzya-prinimat-pri-koronaviruse/ Эта информация для меня оказалась полезна, добавила в избранное.
anonymous
Anonymous
2021年06月27日
Аналитические данные от врачей и экспертов о 2019-nCoV, на авторитетном интернет-издании Coronavirus-Control.ru со ссылками на официальные и государственные источники Роспотребнадзор - https://coronavirus-control.ru/kak-zapisatsya-na-vakczinacziyu-ot-koronavirusa/ Эта информация для меня была крайне полезна, добавил в закладки.
anonymous
Anonymous
2021年06月27日
<a href="https://internationalwealth.info/foreign-bank-accounts/how-to-open-an-account-in-a-swiss-bank-for-individuals-in-2020/">открыть счет в швейцарии</a>
anonymous
Anonymous
2021年06月30日
<a href="https://pony-town.ru">скачать бесплатно песню pony town</a>
anonymous
Anonymous
2021年06月30日
cialis definition <a href="https://cialisnaster.com/">how to take cialis 20mg</a> when will generic cialis be available in the us
anonymous
Anonymous
2021年06月30日
online viagra <a href="https://theviagramaster.com/">https://theviagramaster.com/</a> over the counter viagra substitute walgreens
anonymous
Anonymous
2021年07月01日
http://diplom-na-dom.ru/
anonymous
Anonymous
2021年07月01日
<a href="http://diplom-na-dom.ru/"> покупка диплома о высшем образовании</a>
anonymous
Anonymous
2021年07月01日
<a href="https://pony-town.ru">скачать трек pony town</a>
anonymous
Anonymous
2021年07月02日
Found something unexpected <a href="https://ancientesotericism.org/lidl-near-me-to-make-your-supermarket-search-hassle-free/">click here</a>
anonymous
Anonymous
2021年07月02日
womens viagra <a href="https://slidnenafilviagramore.com/">viagra generic</a> canadian pharmacy viagra
anonymous
Anonymous
2021年07月03日
female viagra pill <a href="https://slidnenafilviagramore.com/">viagra alternative</a> sildenafil 100 mg tablet
anonymous
Anonymous
2021年07月03日
viagra triangle chicago <a href="https://topviagralove.org/">roman sildenafil</a> sildenafil prescription
anonymous
Anonymous
2021年07月03日
<a href="http://eduvuz.ru/">купила диплом о высшем образовании</a>
anonymous
Anonymous
2021年07月04日
http://www.wgsjys.com/home.php?mod=space&uid=111479
anonymous
Anonymous
2021年07月04日
http://eduvuz.ru/
anonymous
Anonymous
2021年07月03日
sildenafil 100 mg prix <a href="https://shopfranviagra.com/">viagra sans ordonnance en pharmacie forum</a> viagra en ligne livraison express
anonymous
Anonymous
2021年07月03日
sildenafil pills <a href="https://slidnenafilviagramore.com/">cvs viagra</a> sildenafil buy
anonymous
Anonymous
2021年07月03日
sildenafil 20 mg <a href="https://shopfranviagra.com/">ordonnance viagra</a> viagra sur ordonnance
anonymous
Anonymous
2021年07月03日
buy real viagra online <a href="https://topviagralove.org/">viagra connect</a> women viagra pills
anonymous
Anonymous
2021年07月03日
http://eduvuz.ru/
anonymous
Anonymous
2021年07月03日
sildenafil mylan 100 mg prix <a href="https://shopfranviagra.com/">shopfranviagra</a> viagra online
anonymous
Anonymous
2021年07月06日
how to use cialis <a href="https://cialisloves.org/">tadalafil 20 mg</a> cialis and viagra
anonymous
Anonymous
2021年07月04日
https://msk-intimcity.ru
anonymous
Anonymous
2021年07月04日
https://funnyway.ru/user/OrpUU/
anonymous
Anonymous
2021年07月05日
http://eduvuz.ru/
anonymous
Anonymous
2021年07月05日
http://tcclub.xyz/home.php?mod=space&uid=58524
anonymous
Anonymous
2021年07月05日
https://filmlord2.net/
anonymous
Anonymous
2021年07月05日
cialis for sale <a href="https://cialisloves.org/">cialis generic</a> cialis vs viagra cost
anonymous
Anonymous
2021年07月06日
<a href="https://sep55.ru/">Обследование технического состояния дома перед покупкой</a>
anonymous
Anonymous
2021年07月05日
viagra prescription <a href="https://missaviagra.com/">cheapest viagra</a> sildenafil otc
anonymous
Anonymous
2021年07月06日
sildenafil costs <a href="https://missaviagra.com/">alternative to viagra</a> sildenafil india
anonymous
Anonymous
2021年07月07日
Medicine information for patients. Cautions. <a href="https://depakote4all.top">can i purchase cheap depakote without prescription</a> in USA Some what you want to know about meds. Get information here.
anonymous
Anonymous
2021年07月07日
Medicine information sheet. Cautions. <a href="https://furosemide4u.top">can i buy generic furosemide</a> in USA Everything what you want to know about drugs. Get information here.
anonymous
Anonymous
2021年07月07日
vardenafil generico 10 mg <a href="https://levitraworlds.com/">levitra active ingredient</a> vardenafil manufactures in india
anonymous
Anonymous
2021年07月08日
vardenafil precio <a href="https://levitraworlds.com/">vardenafil 20</a> vardenafil drugs.com
anonymous
Anonymous
2021年07月08日
cialis coupon cvs <a href="https://tadalafilmast.com/">cialis no prescription</a> cialis goodrx
anonymous
Anonymous
2021年07月07日
cialis india <a href="https://tadalafilmast.com/">over the counter cialis</a> cialis otc 2017
anonymous
Anonymous
2021年07月07日
http://www.frames.bookmarking.site/News/front-sign-llc/
anonymous
Anonymous
2021年07月14日
vardenafil canada <a href="https://levitrastops.net/">levitra prescription online discount levitra</a> vardenafil precio
anonymous
Anonymous
2021年07月14日
vardenafil hydrochloride used-to-treat <a href="https://mylevitralife.com/">discount levitra online levitra</a> vardenafil and grapefruit
anonymous
Anonymous
2021年07月15日
https://odstroy.ru/magkie-okna-dla-terras-i-besedok-ustrojstvo-sovety-kakie-lucse-kupit-montaz/
anonymous
Anonymous
2021年07月16日
<a href="https://domalech.ru">can you buy trazodone without a prescription</a>
anonymous
Anonymous
2021年07月16日
<a href="https://krasota4u.ru">where to buy trazodone without dr prescription</a>
anonymous
Anonymous
2021年07月17日
cialis 5mg <a href="https://cialissportsfran.org/">https://cialissportsfran.org/</a> cialis 100
anonymous
Anonymous
2021年07月17日
commande cialis <a href="https://cialisspotsfrance.net/">cialis 20 mg</a> cialis 15 mg dosage
anonymous
Anonymous
2021年07月18日
<a href="https://arte.style/katalog-effektov/shtukaturka-loft-industrial/">купить декоративную штукатурку для стен</a>
anonymous
Anonymous
2021年07月19日
<a href="https://krasota4u.ru">trazodone without dr prescription</a>
anonymous
Anonymous
2021年07月19日
<a href="https://3522.ru/podgotovka-k-svadbe/naturalnyy-shokolad-ruchnoy-raboty-teper-dostupen-kazhdomu/">cacaolavka.ru/</a>
anonymous
Anonymous
2021年07月20日
buy sildenafil <a href="https://mastviagra.com/">viagra alternative</a> alternatives to viagra
anonymous
Anonymous
2021年07月20日
best over the counter viagra <a href="https://viagramores.org/">natural viagra for men</a> female viagra walmart
anonymous
Anonymous
2021年07月21日
Medicines information. Brand names. <a href="https://flagyl4people.top">flagyl without a prescription</a> in Canada Some what you want to know about drug. Read now.
anonymous
Anonymous
2021年07月21日
Drugs information. Drug Class. <a href="https://flagyl4people.top">buying flagyl for sale</a> in USA Everything news about drugs. Get information here.
anonymous
Anonymous
2021年07月21日
cialis drug <a href="https://cialisdotan.com/">cialis generic timeline</a> cialis and bph
anonymous
Anonymous
2021年07月22日
how to buy cialis online <a href="https://cialistodos.com/">cheap generic cialis</a> what doe cialis look like
anonymous
Anonymous
2021年07月22日
Medicine prescribing information. What side effects? <a href="https://levitra4people.top">order levitra without rx</a> in US Actual what you want to know about pills. Read information now.
anonymous
Anonymous
2021年07月22日
Meds information for patients. Short-Term Effects. <a href="https://plaquenil4people.top">plaquenil prices</a> in US Everything trends of drug. Get information here.
anonymous
Anonymous
2021年07月22日
Medicines information. Long-Term Effects. <a href="https://valtrex4people.top">valtrex online</a> in Canada Actual information about medicine. Get information here.
anonymous
Anonymous
2021年07月23日
Medicine prescribing information. Cautions. <a href="https://levitra4people.top">cheap levitra no prescription</a> in US All what you want to know about drug. Read now.
anonymous
Anonymous
2021年07月24日
Medication information for patients. Brand names. <a href="https://plaquenil4people.top">buy cheap plaquenil</a> in US Everything what you want to know about drugs. Get information here.
anonymous
Anonymous
2021年07月25日
Medicament prescribing information. Long-Term Effects. <a href="https://valtrex4people.top">can i buy valtrex without rx</a> in US Some news about meds. Read now.
anonymous
Anonymous
2021年07月26日
Последние статьи <a href="https://rail-club.ru/forum/viewtopic.php?p=594333">о ковид пандемии</a> сильно необычны!
anonymous
Anonymous
2021年07月26日
Medicines prescribing information. Short-Term Effects. <a href="https://valtrex4people.top">where to buy valtrex</a> in US Some about pills. Read information here.
anonymous
Anonymous
2021年07月26日
https://www.alltolearn.com/yqxf5xu/
anonymous
Anonymous
2021年07月26日
<a href="https://domalech.ru">cost generic trazodone without prescription</a>
anonymous
Anonymous
2021年07月26日
Последние публикации <a href="https://addcatalogs.manyweb.ru/review/coronavirusmoskva.ru.html">о короне</a> очень заманчивы!
anonymous
Anonymous
2021年07月27日
http://selidovo.ukrbb.net/viewtopic.php?f=24&t=1487
anonymous
Anonymous
2021年07月27日
https://adopt10plus.com/question/wcp30vf/
anonymous
Anonymous
2021年07月28日
Drugs prescribing information. What side effects? <a href="https://synthroid4all.top">where to buy generic synthroid</a> in the USA Everything information about medicines. Read information now.
anonymous
Anonymous
2021年07月28日
Meds information sheet. What side effects can this medication cause? <a href="https://celebrex4all.top">where can i get celebrex</a> in the USA Best news about drugs. Read now.
anonymous
Anonymous
2021年07月30日
<a href="https://kmsauto-win.ru/активатор-windows-10/">активатор Windows 10 KMS Auto</a>
anonymous
Anonymous
2021年07月30日
Последние публикации <a href="https://urlscan.io/result/edb25e12-7b2b-4715-ad85-f3694783e03d">о SARS-CoV-2</a> весьма любопытны!
anonymous
Anonymous
2021年07月31日
Medicines information leaflet. What side effects can this medication cause? <a href="https://kamagra4people.top">where to buy cheap kamagra tablets</a> in USA Actual trends of medication. Get information here.
anonymous
Anonymous
2021年08月01日
Medication information for patients. Brand names. <a href="https://kamagra4people.top">where can i get kamagra</a> in the USA Actual information about medication. Read information now.
anonymous
Anonymous
2021年08月02日
Medicines information sheet. What side effects? <a href="https://eriacta4people.top">how to get eriacta pill</a> in US Best news about medicine. Read here.
anonymous
Anonymous
2021年07月31日
Drug information. Brand names. <a href="https://tadacip4people.top">cost of cheap tadacip no prescription</a> in Canada Best what you want to know about pills. Get now.
anonymous
Anonymous
2021年08月01日
Medicine information sheet. Drug Class. <a href="https://eriacta4people.top">where to buy cheap eriacta no prescription</a> in US Best what you want to know about medicament. Read now.
anonymous
Anonymous
2021年08月02日
Medicament information for patients. Effects of Drug Abuse. <a href="https://eriacta4people.top">cheap eriacta pills</a> in US All news about meds. Get information now.
anonymous
Anonymous
2021年08月01日
Meds information leaflet. Brand names. <a href="https://tadacip4people.top">get tadacip</a> in Canada All about pills. Read information here.
anonymous
Anonymous
2021年08月11日
Create anonymous bitcoin wallet without verification. Fast sending to the blockchain without commission. Read more at https://www.google.com/url?q=https://www.bitcoinofficial.org/
anonymous
Anonymous
2021年08月12日
Create anonymous bitcoin wallet without verification. Fast sending to the blockchain without commission. Read more at https://www.google.com.hk/url?q=https://www.bitcoinofficial.org/
anonymous
Anonymous
2021年08月12日
Create anonymous bitcoin wallet without verification. Fast sending to the blockchain without commission. Read more at https://www.google.co.jp/url?q=https://www.bitcoinofficial.org/
anonymous
Anonymous
2021年08月13日
Create anonymous bitcoin wallet without verification. Fast sending to the blockchain without commission. Read more at https://www.google.fr/url?q=https://www.bitcoinofficial.org/
anonymous
Anonymous
2021年08月13日
Create anonymous bitcoin wallet without verification. Fast sending to the blockchain without commission. Read more at https://www.google.es/url?q=https://www.bitcoinofficial.org/
anonymous
Anonymous
2021年08月14日
Create anonymous bitcoin wallet without verification. Fast sending to the blockchain without commission. Read more at https://www.google.com.tr/url?q=https://www.bitcoinofficial.org/
anonymous
Anonymous
2021年08月14日
Create anonymous bitcoin wallet without verification. Fast sending to the blockchain without commission. Read more at https://www.google.pl/url?q=https://www.bitcoinofficial.org/
anonymous
Anonymous
2021年08月20日
prix cialis 20mg boite de 8 <a href="https://cialismom.com/">tadalafil</a> pharmacy rx one cialis
anonymous
Anonymous
2021年08月20日
prix du cialis en pharmacie <a href="https://cialiskoms.org/">cialiskoms.org</a> acheter cialis canada sans prescription
anonymous
Anonymous
2021年08月26日
<a href="https://domalech.ru/">trazodone orapred</a>
anonymous
Anonymous
2021年08月26日
<a href="https://domalech.ru/">trazodone for dogs eyes</a>
anonymous
Anonymous
2021年08月27日
prednisolone syrup for babies <a href="https://prednisoloneshop.com/">otc prednisone</a> prednisone manufacturer
anonymous
Anonymous
2021年08月27日
tamoxifen gynecomastia before and after <a href="https://tamoxifenworld.com/">how to prevent hair loss while on tamoxifen</a> tamoxifen research
anonymous
Anonymous
2021年08月27日
<a href="https://domalech.ru/">prednisolon tabletten</a>
anonymous
Anonymous
2021年08月31日
<a href="https://domalech.ru/">depo trazodone</a>
anonymous
Anonymous
2021年08月31日
<a href="https://domalech.ru/">trazodone eye drops dosage</a>
anonymous
Anonymous
2021年09月02日
viagra canadian pharmacy ezzz <a href="https://edviagramaster.net/">cheap viagra</a> where to buy female viagra
anonymous
Anonymous
2021年09月03日
cialis prices <a href="https://rxcialislife.net/">online purchase of tadalafil in india</a> cialis for prostate
anonymous
Anonymous
2021年09月05日
Meds information. Brand names. <a href="https://fluoxetine4u.top">can you buy generic fluoxetine prices</a> in the USA Everything what you want to know about drug. Read now.
anonymous
Anonymous
2021年09月05日
Drug information leaflet. Brand names. <a href="https://lasix4u.top">cheap lasix price</a> in the USA Some information about drugs. Read now.
anonymous
Anonymous
2021年09月11日
JGIgNLgiy9tYGHIYfyfrGKJbg8i6TGuigf86rOUhg97BikofvguTOPig*IGkjf8