1 条题解
-
0
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 10; bool c[N]; int a[N], head = 0, tail = -1, n, m, cnt, b; void push(int x) { a[++tail] = x; } void pop() { head++; } int query() { return tail - head + 1; } int main() { cin >> m >> n; for (int i = 0; i < n; i++) { cin >> b; if (c[b]) continue; cnt++; if (query() == m) { c[a[head]] = 0; pop(); } c[b] = 1; push(b); } cout << cnt; return 0; } /* 题目名: [NOIP 2010 提高组] 机器翻译 oj题号: p1540 作者: Li Mingkai 日期: 2026-07-14 说明: 数组模拟的做的做法 */
信息
- ID
- 5652
- 时间
- 1000ms
- 内存
- 125MiB
- 难度
- 3
- 标签
- 递交数
- 182
- 已通过
- 55
- 上传者