bzoj 1826 JSOI2010 快取交換

2021-08-08 19:59:47 字數 508 閱讀 7130

求最少的排程次數。

貪心。

假如對於乙個數,以後都沒有出現過,那麼一定可以換掉。

而對於其他的,記錄下它下次出現的位置,那麼將最遠的換掉就可以了。

正確性顯然。

code:

#include

#include

#include

#include

#include

#include

#include

using

namespace

std;

map mp;

int n,m,a[100010],tot=0;

int nex[100010],ans=0;

struct node

};set

q;int main()

else

}if(nex[i]!=0)

}printf("%d",ans);

}

bzoj1826 JSOI2010 快取交換

傳送門 界定記憶體放進去還是出來的是他下一次出現的位置 沒有是n 1 顯然先出現的比後出現的更優。然後優先佇列水一波。include include include include include include include include using namespace std const i...

BZOJ 1826 JSOI2010 快取交換

時間限制 10 sec 記憶體限制 64 mb 提交 955 解決 516 提交 在計算機中,cpu只能和快取記憶體cache直接交換資料。當所需的記憶體單元不在cache中時,則需要從主存裡把資料調入cache。此時,如果cache容量已滿,則必須先從中刪除乙個。例如,當前cache容量為3,且已...

1826 JSOI2010 快取交換

在計算機中,cpu只能和快取記憶體cache直接交換資料。當所需的記憶體單元不在cache中時,則需要從主存裡把資料調入cache。此時,如果cache容量已滿,則必須先從中刪除乙個。例如,當前cache容量為3,且已經有編號為10和20的主存單元。此時,cpu訪問編號為10的主存單元,cache命...