欧美1区2区3区激情无套,两个女人互添下身视频在线观看,久久av无码精品人妻系列,久久精品噜噜噜成人,末发育娇小性色xxxx

牛客網(wǎng)這個bug真有趣

同樣一個代碼,我在本地跑,在線調(diào)試時都會輸出正確答案130,但提交就會輸出錯誤答案120。下面是兩個圖片和代碼

#include <iostream>

#include <algorithm>
#include <set>
#include <vector>
#include <unordered_map>

using namespace std;

struct ShopThing{
    int cost;
    int importantValue;
    int masterId;
};
struct MainThing
{
    int cost;
    int importantValue;
    vector<ShopThing> subThings;
};


int main() {
    // 價格 除 10 ,最后在乘 10
    int totalMoney, tmp;
    cin >> totalMoney >> tmp;
    totalMoney = totalMoney / 10;
    unordered_map<int, MainThing> allMainThing;
    for(int i = 0 ; i < tmp; ++i){
        int cost, importantValue, masterId;
        cin >> cost >> importantValue >> masterId;
        if (masterId == 0){
            allMainThing[i + 1].cost = cost / 10;
            allMainThing[i + 1].importantValue = importantValue;
        } else {
            allMainThing[masterId].subThings.push_back({cost / 10, importantValue, masterId});
        }
    }
    // 開始動態(tài)規(guī)劃
    int nowThingId = 0;
    vector<vector<int>> dpList = vector<vector<int>>(allMainThing.size() + 1, vector<int>(totalMoney + 1, 0));
    // dpList[y][x]  y 表示 考慮到1 - y 的所有物品, x表示考慮到現(xiàn)有總錢數(shù)為 x*10, 值為最大滿意度
    for (auto& nowMainThing : allMainThing){
        ++nowThingId;
        for (int nowMony = 1; nowMony <= totalMoney; ++nowMony ){
            // 考慮 僅主件 主件+1附件 主件+2附件
            // 對每個購買計劃,判斷是否有足夠的錢來買,如果沒有就不買,有就買??纯茨膫€的收益高
            int subAns = 0;
            int cost, importantValue;
            // 僅主件
            cost = nowMainThing.second.cost;
            importantValue = nowMainThing.second.importantValue;
            if (nowMony >= cost){
                subAns = max(dpList[nowThingId - 1][nowMony - cost] + cost * importantValue, subAns);
            } else {
                subAns = max(dpList[nowThingId - 1][nowMony], subAns);
            }
            // 主件 + 附件A 
            if(nowMainThing.second.subThings.size() >= 1){
                cost = nowMainThing.second.cost + nowMainThing.second.subThings[0].cost;
                if (nowMony >= cost){
                    int nowIncome = nowMainThing.second.cost * nowMainThing.second.importantValue;
                    nowIncome +=  nowMainThing.second.subThings[0].cost * nowMainThing.second.subThings[0].importantValue;
                    subAns = max(dpList[nowThingId - 1][nowMony - cost] + nowIncome, subAns);

                }
            } 
            if(nowMainThing.second.subThings.size() == 2){
                cost = nowMainThing.second.cost + nowMainThing.second.subThings[1].cost;
                if (nowMony >= cost){
                    int nowIncome = nowMainThing.second.cost * nowMainThing.second.importantValue;
                    nowIncome +=  nowMainThing.second.subThings[1].cost * nowMainThing.second.subThings[1].importantValue;
                    subAns = max(dpList[nowThingId - 1][nowMony - cost] + nowIncome, subAns);
                }
                
                cost = nowMainThing.second.cost + \
                nowMainThing.second.subThings[0].cost + \
                nowMainThing.second.subThings[1].cost;
                if (nowMony >= cost){
                    int nowIncome = nowMainThing.second.cost * nowMainThing.second.importantValue;
                    nowIncome +=  nowMainThing.second.subThings[0].cost * nowMainThing.second.subThings[0].importantValue;
                    nowIncome +=  nowMainThing.second.subThings[1].cost * nowMainThing.second.subThings[1].importantValue;
                    subAns = max(dpList[nowThingId - 1][nowMony - cost] + nowIncome, subAns);

                }

            } 
            dpList[nowThingId][nowMony] = subAns;
        }   
    }
    cout << dpList[allMainThing.size()][totalMoney] * 10 <<endl;
    return 0;
}
// 64 位輸出請用 printf("%lld")

全部評論

相關(guān)推薦

ResourceUtilization:算法很難了,現(xiàn)在都需要相關(guān)論文還有對應(yīng)的實習(xí),可以先試試中廠
點贊 評論 收藏
分享
評論
點贊
收藏
分享

創(chuàng)作者周榜

更多
??途W(wǎng)
牛客企業(yè)服務(wù)