Submission #344707

#TimeUsernameProblemLanguageResultExecution timeMemory
344707infertechno2Bomb (IZhO17_bomb)C++14
3 / 100
1 ms512 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

    ll battleground[2501];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m,smallest_territory=2501;
    cin>>n>>m;
    if(m==1)swap(n,m);
    ll curr_terr_size=0;
    for(ll i=0;i<m;i++){
        cin>>battleground[i];
        if(battleground[i]==1){
            curr_terr_size++;
        }else{
            if(curr_terr_size!=0)smallest_territory=min(smallest_territory,curr_terr_size);
            curr_terr_size=0;
        }
    }
    if(curr_terr_size!=0)smallest_territory=min(smallest_territory,curr_terr_size);
    if(smallest_territory==2501)smallest_territory=0;
    cout<<smallest_territory<<endl;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...