Submission #499508

# Submission time Handle Problem Language Result Execution time Memory
499508 2021-12-28T14:18:23 Z adam Lampice (COCI21_lampice) C++14
0 / 50
0 ms 204 KB
#include <iostream>

using namespace std;

int main()
{
   int n,k;
   int p;
   bool o=0;
   cin>>n>>k;
   int a[n];
   for(int i=0;i<n;i++){
    cin>>a[i];
    }int sum=0;
    for(int i=0;i<n;i++){
    if(a[i]==a[i-1]){sum++;p=a[i];}
    if(sum==k){o=1;break;}
    }
    if(o==1)cout<<'1'<<endl<<p;
    else cout<<"-1";
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:19:30: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
   19 |     if(o==1)cout<<'1'<<endl<<p;
      |                              ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -