mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2025-01-11 18:51:59 +00:00
P1540 机器翻译
R38909558
This commit is contained in:
parent
219f8bdb60
commit
64aa29fd27
34
problem/P1540/P1540.cpp
Normal file
34
problem/P1540/P1540.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
// R38909558
|
||||
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int m, n, t, f = 0, ans = 0;
|
||||
bool flag = false;
|
||||
vector<int> memory;
|
||||
queue<int> mq;
|
||||
cin >> m >> n;
|
||||
for (int i = 0; i < n; i++) {
|
||||
cin >> t;
|
||||
ans++;
|
||||
flag = false;
|
||||
for (int j = f; j < memory.size(); j++) {
|
||||
if (memory[j] == t) {
|
||||
ans--;
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if (!flag) {
|
||||
memory.push_back(t);
|
||||
mq.push(t);
|
||||
}
|
||||
if (mq.size() > m) {
|
||||
f++;
|
||||
mq.pop();
|
||||
}
|
||||
}
|
||||
cout << ans << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user