Submission #666981

# Submission time Handle Problem Language Result Execution time Memory
666981 2022-11-30T06:13:43 Z Kenpar Lampice (COCI21_lampice) C++17
50 / 50
1 ms 324 KB
#include "bits/stdc++.h"
using namespace std;

#define ll long long
#define endl '\n'

const ll MOD = 1e9+7;
const ll INF = 1e18;
const ll MAX = 1e5;

void solve(){	
	int n,k; cin>>n>>k;

	int arr[n];
	for(int i = 0; i < n; i++){
		cin>>arr[i];
	}

	int ans = 0;
	vector<int> ansVec;
	for(int i = 0; i < n; i++){
		int l = 0, r = i;

		while(r < n){
			int curAns = 0;
			int cur = l;
			int curIndex = l;
			while(cur < n){
				if(arr[cur] == arr[curIndex]){
					cur++;
					curIndex++;

					if(curIndex > r){
						curIndex = l;
						curAns++;
					}
				}else{
					break;
				}
			}

			if(ans < curAns){
				ans = curAns;
				ansVec.clear();

				for(int i = l; i <= r; i++){
					ansVec.push_back(arr[i]);
				}
			}

			l++;
			r++;
		}
	}
	if(ans >= k){
		cout<<ansVec.size()<<endl;

		for(int a : ansVec) cout<<a<<" ";
	}else{
		cout<<-1;
	}
	
}	 

int main()
{
    cin.tie(NULL);
    ios::sync_with_stdio(NULL);
    int t = 1;

    //cin>>t;
    int temp = t;
    while(t--){
        //cout<<"Case #"<<temp - t<<" > "<<endl;
        solve();

        cout<<endl;
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:72:9: warning: unused variable 'temp' [-Wunused-variable]
   72 |     int temp = t;
      |         ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 324 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 320 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct