Submission #83346

#TimeUsernameProblemLanguageResultExecution timeMemory
83346charlies_mooRasvjeta (COCI17_rasvjeta)C++17
50 / 50
2 ms532 KiB
#include <cstdio> #include <cstring> int main() { int n, m, k; scanf("%d", &n); scanf("%d", &m); scanf("%d", &k); bool s[n]; memset(s, 0, sizeof(s)); for (int i = 0; i < m; i++) { int a; scanf("%d", &a); a--; int l = a - k; if (l < 0) { l = 0; } int r = a + k; if (r >= n) { r = n - 1; } for (int j = l; j <= r; j++) { s[j] = 1; } } int ans = 0; for (int i = 0; i < n; i++) { if (s[i] == 0) { ans++; int l = i; int r = i + 2 * k; if (r >= n) { r = n - 1; } for (int j = l; j <= r; j++) { s[j] = 1; } } } printf("%d\n", ans); return 0; }

Compilation message (stderr)

rasjveta.cpp: In function 'int main()':
rasjveta.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
rasjveta.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &m);
     ~~~~~^~~~~~~~~~
rasjveta.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &k);
     ~~~~~^~~~~~~~~~
rasjveta.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a);
         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...