Submission #1191499

#TimeUsernameProblemLanguageResultExecution timeMemory
1191499moha1111Stove (JOI18_stove)C++20
0 / 100
0 ms320 KiB
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#define all(a) a.begin() , a.end()
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>indexed_multiset;

void solve()
{
    int n , k;
    cin >> n >> k;
    int b[n + 1] = {};
    for(int i = 1 ; i <= n ; i++)
    {
        int a;
        cin >> a;
        b[i] = b[i - 1] + a;
    }
    int ans = 1000000000;
    for(int i = 1 ; i <= n - k + 1; i++)
        ans = min(ans , b[i + k] - b[i - 1] + 1);

    cout << ans + (n - k);

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--)
        solve();


}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...