제출 #209147

#제출 시각아이디문제언어결과실행 시간메모리
209147pavementTelefoni (COCI17_telefoni)C++17
80 / 80
20 ms380 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

int N, D, U;
vector<int> P;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N >> D;
	for (int i = 1, B; i <= N; i++) {
		cin >> B;
		if (B) P.push_back(i);
	}
	for (int p = 1; p < N; ) {
		auto it = upper_bound(P.begin(), P.end(), p + D);
		if (it != P.begin()) {
			--it;
			if (*it > p) p = *it;
			else U++, p += D;
		} else U++, p += D;
	}
	cout << U << '\n';
}

컴파일 시 표준 에러 (stderr) 메시지

telefoni.cpp:8:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...