Submission #75046

# Submission time Handle Problem Language Result Execution time Memory
75046 2018-09-08T06:42:29 Z charlies_moo Telefoni (COCI17_telefoni) C++17
Compilation error
0 ms 0 KB
#include <iostream>

int main() {
    int n, d;
    cin >> n >> d;
    int lt;
    int c = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a == 1) {
            lt = a;
        } else if (i - lt == d) {
            lt = i;
            c++;
        }
    }

    cout << c << endl;

    return 0;
}

Compilation message

telefoni.cpp: In function 'int main()':
telefoni.cpp:5:5: error: 'cin' was not declared in this scope
     cin >> n >> d;
     ^~~
telefoni.cpp:5:5: note: suggested alternative:
In file included from telefoni.cpp:1:0:
/usr/include/c++/7/iostream:60:18: note:   'std::cin'
   extern istream cin;  /// Linked to standard input
                  ^~~
telefoni.cpp:19:5: error: 'cout' was not declared in this scope
     cout << c << endl;
     ^~~~
telefoni.cpp:19:5: note: suggested alternative:
In file included from telefoni.cpp:1:0:
/usr/include/c++/7/iostream:61:18: note:   'std::cout'
   extern ostream cout;  /// Linked to standard output
                  ^~~~
telefoni.cpp:19:18: error: 'endl' was not declared in this scope
     cout << c << endl;
                  ^~~~
telefoni.cpp:19:18: note: suggested alternative:
In file included from /usr/include/c++/7/iostream:39:0,
                 from telefoni.cpp:1:
/usr/include/c++/7/ostream:590:5: note:   'std::endl'
     endl(basic_ostream<_CharT, _Traits>& __os)
     ^~~~