one unfinished
This commit is contained in:
28
CSES - CSES Problem Set/Playlist.cpp
Normal file
28
CSES - CSES Problem Set/Playlist.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Created by darian on 07.06.24.
|
||||
//
|
||||
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
using ll = long long;
|
||||
|
||||
int main() {
|
||||
int n; cin >> n;
|
||||
vector<ll> in(n);
|
||||
for (auto &e : in) cin >> e;
|
||||
int lo = 0;
|
||||
int hi = 0;
|
||||
int max_count = 1;
|
||||
set<ll> current = {in[0]};
|
||||
|
||||
while (hi < n - 1) {
|
||||
hi++;
|
||||
while (current.count(in[hi])) {
|
||||
current.erase(in[lo]);
|
||||
lo++;
|
||||
}
|
||||
current.insert(in[hi]);
|
||||
max_count = max(max_count, (int)current.size());
|
||||
}
|
||||
cout << max_count << endl;
|
||||
}
|
||||
Reference in New Issue
Block a user