Submission #241328

# Submission time Handle Problem Language Result Execution time Memory
241328 2020-06-23T23:40:46 Z Nayeon_A_Bunny Telefoni (COCI17_telefoni) C++17
8 / 80
26 ms 5760 KB
#include <bits/stdc++.h>
using namespace std;

template<typename TH>
void _dbg(const char* sdbg, TH h) {
	cerr << sdbg << " = " << h << "\n";
}

template<typename TH, typename... TA>
void _dbg(const char* sdbg, TH h, TA... t) {
	while (*sdbg != ',') cerr << *sdbg++;
	cerr << " = " << h << ",";
	_dbg(sdbg + 1, t...);
}

#define db(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define chkpt cerr << "------\n";

const int N=3e5+5;

int n,d,a[N];
int nxt[N];

int main() {
//    freopen("COCI17_TELEFONI.INP","r",stdin);
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>n>>d;
	for(int i=1;i<=n;++i){
        cin>>a[i];
	}
	nxt[n]=n+1;
	for(int i=n-1;i>=1;--i){
        nxt[i]=a[i+1]?(i+1):nxt[i+1];
	}
	int last=1;
	while(last<=n){
        if(nxt[last]-last>d){
            break;
        }
        last=nxt[last];
	}
	int ans=0;
	if(last!=n){
        last+=d;
        while(last!=n){
            ans+=a[last]==0;
            last+=d;
        }
	}
	cout<<ans<<'\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 5 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 23 ms 5760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 26 ms 5752 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 25 ms 5752 KB Execution killed with signal 11 (could be triggered by violating memory limits)