답안 #241329

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
241329 2020-06-23T23:42:41 Z Nayeon_A_Bunny Telefoni (COCI17_telefoni) C++17
24 / 80
24 ms 2688 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 5 ms 384 KB Output isn't correct
4 Correct 4 ms 384 KB Output is correct
5 Incorrect 4 ms 384 KB Output isn't correct
6 Incorrect 5 ms 384 KB Output isn't correct
7 Incorrect 4 ms 384 KB Output isn't correct
8 Incorrect 23 ms 2688 KB Output isn't correct
9 Incorrect 23 ms 2688 KB Output isn't correct
10 Incorrect 24 ms 2688 KB Output isn't correct