Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- ios_base::sync_with_stdio(false);
- int n, k;
- cin >> n >> k;
- vector<int> v(n);
- for(int i = 0; i < n; i++) {
- cin >> v[i];
- }
- int res = 0;
- for(int i = 0; i < n; i++) {
- for(int j = i; j < n; j++) {
- vector<int> cnt(k, 0);
- for(int l = i; l <= j; l++) {
- if(v[l] < k) {
- cnt[v[l]]++;
- }
- }
- bool ok = true;
- for(int l = 0; l < k; l++) {
- if(cnt[l] != 3) {
- ok = false;
- break;
- }
- }
- if(ok) {
- res = max(res, j - i + 1);
- }
- }
- }
- cout << res << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment