Rezultati

Up. imeNalogaJezikRezultatČas oddaje
sSrcem-2018 Niz C++ 100/100OK 19. apr '18 @ 17:26

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 3,129 MiB 0,004 s OK
#2 10/10 3,047 MiB 0,000 s OK
#3 10/10 3,172 MiB 0,004 s OK
#4 10/10 3,168 MiB 0,004 s OK
#5 10/10 3,172 MiB 0,010 s OK
#6 10/10 3,176 MiB 0,010 s OK
#7 10/10 3,313 MiB 0,010 s OK
#8 10/10 3,172 MiB 0,010 s OK
#9 10/10 3,176 MiB 0,004 s OK
#10 10/10 3,313 MiB 0,016 s OK

Ocenjevani program (niz.cpp):
#include <iostream>
#include <string>
#include <string.h>

using namespace std;

int getVal( string& niz, int& size) 
{
  int num = 0;
  for( int i = 0; i < size; i++) {
    if( strcmp("010",niz.substr(i,3).c_str()) == 0)
    {
      num++;
      i+=2;
    }
  }
  return num;
}

int main()
{
  int size;
  ios_base::sync_with_stdio(false);
  cin >> size;
  size -= size%3;
  string niz;

  cin >> niz;
  cout << getVal(niz,size) << endl;
}