#include <bits/stdc++.h>
#define fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
using namespace std;
void solve() {
int n,k;
cin>>n>>k;
vector<int>x(n);
vector<int>y;
for(int i=0;i<n;i++){
cin>>x[i];
}
for(int i=1;i<=(n/k);i++){
int cnt=i;
int a=i;
for(int j=0;j<n-i;j++){
if(cnt/i>=k){
cout<<i<<endl;
for(int i=0;i<a;i++){
cout<<y[i]<<" ";
}
cout<<endl;
return;
}
if(x[j]==x[j+i]){
cnt+=1;
y.push_back(x[j]);
}
else if(cnt>i){
cnt=i;
y.clear();
}
}
}
cout<<-1<<endl;
}
int32_t main(){
fast
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |