Submission #23097

# Submission time Handle Problem Language Result Execution time Memory
23097 2017-05-03T05:21:30 Z model_code Telefoni (COCI17_telefoni) C++11
80 / 80
23 ms 1116 KB
#include <cstdio>
#include <string>
#include <vector>
#include <map>
#include <cstdlib>
#include <algorithm>
#include <cstring>

using namespace std;

typedef long long llint;
typedef pair <int, int> pii;

int n, d;

int main (void){
  scanf("%d%d", &n, &d);
  int last = 0;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int x; scanf("%d", &x);
    if (x == 1) last = i;
    if (i - last == d) {
      ++ans;
      last = i;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Compilation message

telefoni.cpp: In function 'int main()':
telefoni.cpp:17:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &n, &d);
                        ^
telefoni.cpp:21:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int x; scanf("%d", &x);
                           ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1116 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
5 Correct 0 ms 1116 KB Output is correct
6 Correct 0 ms 1116 KB Output is correct
7 Correct 0 ms 1116 KB Output is correct
8 Correct 23 ms 1116 KB Output is correct
9 Correct 23 ms 1116 KB Output is correct
10 Correct 23 ms 1116 KB Output is correct