[HNOI2005] 虚拟内存 80wa 求调

题目(https://www.xinyoudui.com/ac/contest/747003D8300053402101126/problem/9504)
code:

#include <bits/stdc++.h>
using namespace std;

const int M = 1e6+1;
int n, m, a[M], chg[M], ans, num;
struct Page {
	int time, cnt;
	friend bool operator< (Page x, Page y) {
		return x.cnt == y.cnt ? x.time > y.time : x.cnt > y.cnt;
	}
};
priority_queue<Page> pq;

int tmp[M];
void discretizing() {
	memcpy(tmp, a, sizeof a);
	sort(tmp+1, tmp+m+1);
	int k = unique(tmp+1, tmp+m+1)-tmp-1;
	for (int i = 1; i <= m; ++i)
		a[i] = lower_bound(tmp+1, tmp+k+1, a[i])-tmp;
}

int main() {
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cin >> n >> m;
	for (int i = 1; i <= m; ++i)
		cin >> a[i];
	discretizing();
	for (int i = 1; i <= m; ++i) {
		if (chg[a[i]]) chg[a[i]]++, ans++;
		if (!chg[a[i]]) {
			if (num < n) chg[a[i]]=1, num++;
			if (num == n) {
				auto cur = pq.top(); pq.pop();
				chg[a[i]]++, chg[a[cur.time]] = 0;
			}
			pq.push({i, chg[a[i]]});
		}
	}
	cout << ans;
	return 0;
}

a[i] = lower_bound(tmp+1, tmp+k+1, a[i])-tmp; 改成 a[i] = lower_bound(tmp+1, tmp+k+1, a[i])-tmp-1;

这个其实没影响,就是把离散化的1到m变成2到m+1,改过交上去还是80