F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Operating system

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 920    Accepted Submission(s): 304


Problem Description
As a CS student, operating system is an important lesson. Today, let¡¯s think about the cache¡¯s working mode. All object accesses go through the cache, so every time an object is accessed, it must be inserted into the cache if it was not already there. If the cache is full, you must take out a object which is already in the cache . All objects are of equal size, and no writes occur in the system, so a cached object is always valid. When the system starts, the cache is empty. To make cache works efficiently, we need find the optimal replacement algorithm. Optimality here means minimizing the number of times an object is read into the cache.
 

Input
There are several test cases in the input.

Each test case begins with three integers(C,N,B), separated by single spaces, telling you how many objects fit in the cache, 0 < C ¡Ü 10000, how many different objects are in the system, C ¡Ü N ¡Ü 100000, and how many accesses, 0 ¡Ü B ¡Ü 100000, will occur. The following line contains B integers between 0 and N-1 (inclusive) indicating what object is accessed.
 

Output
For each test case, output one integer, indicating the least number of times an object must be read into the cache to handle the accesses.
 

Sample Input
1 2 3 0 1 0 2 2 3 0 1 0
 

Sample Output
3 2
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 07:49:54, Gzip enabled