Skip to content

Commit 354e07d

Browse files
committed
atcoder/abc060C
1 parent 33df280 commit 354e07d

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

atcoder/abc060/C/main.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = long long;
5+
6+
int N, T;
7+
vector<int> ts;
8+
9+
int solve() {
10+
int X = 0;
11+
int b = 0, e = 0;
12+
for (auto t : ts) {
13+
if (e < t) {
14+
X += (e - b);
15+
b = t;
16+
e = t + T;
17+
} else {
18+
e = t + T;
19+
}
20+
}
21+
X += (e - b);
22+
return X;
23+
}
24+
25+
int main() {
26+
ios_base::sync_with_stdio(false);
27+
cin.tie(0); cout.tie(0);
28+
29+
cin >> N >> T;
30+
ts.assign(N, 0);
31+
for (int i = 0; i < N; ++i) {
32+
cin >> ts[i];
33+
}
34+
cout << solve() << endl;
35+
36+
return 0;
37+
}

0 commit comments

Comments
 (0)