답안 #1017250

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1017250 2024-07-09T06:57:08 Z vjudge1 Lampice (COCI21_lampice) C++17
50 / 50
1 ms 600 KB
#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];
}
if(k==1){
    cout<<1<<endl;
    cout<<x[0]<<endl;
    return;
}
for(int i=1;i<=(n/k);i++){
    int cnt=i;
    for(int j=0;j<n-i;j++){
        if(cnt/i>=k){
            cout<<i<<endl;
            for(int s=0;s<i;s++){
                cout<<y[s]<<" ";
            }
            cout<<endl;
            return;
        }
        if(x[j]==x[j+i]){
            cnt+=1;
            y.push_back(x[j]); 
        }
        else if(cnt>i){
            cnt=i;
            y.clear();
        }
        if(cnt/i>=k){
            cout<<i<<endl;
            for(int s=0;s<i;s++){
                cout<<y[s]<<" ";
            }
            cout<<endl;
            return;
        }

    }
}
cout<<-1<<endl;
}
int32_t main(){
    fast
    solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 600 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 452 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct