Submission #1260505

#TimeUsernameProblemLanguageResultExecution timeMemory
1260505wedonttalkanymoreTelefoni (COCI17_telefoni)C++20
80 / 80
62 ms4936 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int long long #define pii pair<ll, ll> #define fi first #define se second const ll N = 3e5 + 5, inf = 1e18, mod = 1e9 + 7, block = 320, lim = 16; int n, d; int a[N], dp[N]; signed main() { ios::sync_with_stdio(false); cin.tie(0); if (fopen(".inp", "r")) { freopen(".inp", "r", stdin); freopen(".out", "w", stdout); } cin >> n >> d; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) dp[i] = inf; dp[0] = 0; for (int i = 1; i <= n; i++) { for (int j = max(0LL, i - d); j < i; j++) { dp[i] = min(dp[i], dp[j] + (a[i] == 0)); } } cout << dp[n]; return 0; }

Compilation message (stderr)

telefoni.cpp: In function 'int main()':
telefoni.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen(".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
telefoni.cpp:20:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         freopen(".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...