Loading... ``` #include <iostream> #include <bitset> using namespace std; const int N = 1e5 + 10; int n, arr[N], ans = 1; bitset <N> bt; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 0; i < n; ++i) cin >> arr[i]; for (int h = 0, t = 0; t < n; ) { while (t < n && !bt[arr[t]]) bt[arr[t++]] = 1; ans = max(ans, t - h); while (h <= t && arr[h] != arr[t]) bt[arr[h++]] = 0; bt[arr[h++]] = 0; } cout << ans; return 0; } ``` 最后修改:2024 年 08 月 08 日 © 允许规范转载 赞 如果觉得我的文章对你有用,请随意赞赏