Schedule(優化測試)

2021-06-27 12:40:11 字數 817 閱讀 3963

簡單地說下題目

有n個test case,我們已經知道這n個test case的執行時間t[0],t[1],..., t[n-1],以及每個test case成功pass的概率p[0], p[1], ... ,p[n-1];

現在要求設定test case的順序,使得按該順序執行這些test case的期望時間最小,

輸入:line 1: one integer n

line 2..n+

1 : one integer ti

and one float pi

separated by one space.輸出

line 1: one float, the minimum expected time

sample input

3

3 0.1

7 0.5

9 0.2

sample output

4.04
可以用類似氣泡排序的演算法做,比較交換兩個相鄰元素後期望執行時間是否減小,若是則交換,若不是則不交換;

double solve(vector> &a)

{ int n=a.size();

if(n==1) return a[0].first;

int t=a[0].first;

double p=1-a[0].second;

double r=t*p;

for(int i=1;i1;i--){

t=a[0].first; p=1-a[0].second;

for(int j=1;j

springboot整合schedule定時任務

說是整合,其實不對,因為springboot本來就自帶定時任務。只需要configuration裡面加上註解 enablescheduling就表示啟動。具體的實現方法裡面用 scheduled cron 0 2 即可。enablescheduling public class scheduled ...

SpringBoot整合Scheduled定時呼叫

作用 spring定時器 定時執行一次或定時輪詢執行一段 使用場景 註解在方法上 引數說明 常用引數 scheduled 引數說明 string cron cron表示式定義了方法執行的時間規則 cron表示式 長度6 7位 seconds minutes hours day month week ...

核心排程 之schedule

學os的時候經常講到處理機 即cpu 的排程也即任務的排程,現如今與linux的核心 聯絡起來。理解處理機排程要回答3個問題 1 排程的時機 2 排程的策略 3 排程的實現 高階排程 為任務建立pcb,裝入記憶體 中級排程 為提高吞吐量和利用率,將任務臨時換出記憶體 swap 低階排程 程序排程,為...