BZOJ2832 宅男小C 模擬退火

2021-07-29 17:03:34 字數 816 閱讀 6958

題目大意:

眾所周知,小c是個宅男,所以他的每天的食物要靠外賣來解決。小c現在有m元錢,他想知道這些錢他最多可以吃多少天。

餐廳提供n種食物,每種食物有兩個屬性,單價pi和保質期si,表示小c需要花pi元才能買到足夠一天吃的這種食物,並且需要在送到si天內吃完,否則食物會變質,就不能吃了,若si為0則意味著必須在送到當天吃完。另外,每次送餐需要額外f元送餐費。

思路:

對小c要訂多少次餐模擬退火一下。

隨機**好!

**:

#include 

const

int maxn = 10005;

using

namespace

std;

typedef

long

long ll;

int n;

ll tot, f, ans;

inline

double ran(void)

struct obj

} o[maxn];

inline

void pre(void)

}inline ll j(ll t)

}ans = max(ans, res);

return res;

}inline

void sa(double t)

}inline

void solve(void)

int main(void)

完。

by g1n0st

28 3 異常 斷言

異常處理 什麼是異常 異常和錯誤的區別 異常發生了是什麼效果 如何檢視報錯資訊 最簡單的異常異常處理 pass 多分支異常處理 l d z t for i in enumerate l 1 print i 0 i 1 try num int input num print l num 1 excep...

leetcode題庫283 移動零

給定乙個陣列 nums,編寫乙個函式將所有 0 移動到陣列的末尾,同時保持非零元素的相對順序。示例 輸入 0,1,0,3,12 輸出 1,3,12,0,0 說明 必須在原陣列上操作,不能拷貝額外的陣列。儘量減少操作次數。思路 使用兩個陣列,將原陣列的不為0的資料依次儲存在新的陣列中,後面補0即可。這...

LeetCode 283 解題及優化

leetcode 283 theend ofit while maintaining the relative order of the non zero elements.for example,given nums 0,1,0,3,12 after calling your function,n...