답안 #499544

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
499544 2021-12-28T15:17:25 Z Abito Lampice (COCI21_lampice) C++14
0 / 50
1 ms 204 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int x=0,y;
    bool b=0;
    for (int i=0;i<n-1;i++)
    {
        if (a[i]==a[i+1])
        {
            x++;
            y=a[i];
        }
        else
        {
            if (x+1>=k)
            {
                b=1;
                break;
            }
            else
                x=0;
        }
    }
    if (k==1)
        cout<<1<<endl<<a[0];
    else if (b)
        cout<<1<<endl<<y;
    else
        cout<<-1;
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:37:24: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   37 |         cout<<1<<endl<<y;
      |                        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -