Submission #499545

# Submission time Handle Problem Language Result Execution time Memory
499545 2021-12-28T15:17:56 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=-1;
    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;
}
# Verdict Execution time Memory 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 1 ms 204 KB Output is correct
5 Incorrect 0 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 ms 204 KB Output is correct
5 Incorrect 0 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -