Skip to content

Commit 29850e7

Browse files
committed
atcoder/abc185D
1 parent 4927b07 commit 29850e7

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

atcoder/abc185/D/main.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = int64_t;
5+
using ff = long double;
6+
7+
int N, M;
8+
vector<int> A;
9+
10+
int solve() {
11+
A.push_back(0);
12+
A.push_back(N + 1);
13+
sort(A.begin(), A.end());
14+
15+
int w = N;
16+
for (int i = 0; i + 1 < A.size(); ++i) {
17+
int space = A[i+1] - A[i] - 1;
18+
if (space > 0) {
19+
w = min(w, space);
20+
}
21+
}
22+
23+
int ans = 0;
24+
for (int i = 0; i + 1 < A.size(); ++i) {
25+
int space = A[i+1] - A[i] - 1;
26+
ans += (space + w - 1) / w;
27+
}
28+
return ans;
29+
}
30+
31+
int main() {
32+
ios_base::sync_with_stdio(false);
33+
cin.tie(0); cout.tie(0);
34+
35+
cin >> N >> M;
36+
A.assign(M, 0);
37+
for (auto &a : A) cin >> a;
38+
cout << solve() << endl;
39+
40+
return 0;
41+
}

0 commit comments

Comments
 (0)