Skip to content

Commit 3b02976

Browse files
committed
[BOJ] 28324 스케이트 연습 (S4)
1 parent 0c9b7f8 commit 3b02976

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

박예진/3주차/260113.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//https://www.acmicpc.net/problem/28324
2+
3+
#include <iostream>
4+
#include <vector>
5+
using namespace std;
6+
7+
int N;
8+
long long V[500001];
9+
10+
int main() {
11+
ios::sync_with_stdio(false);
12+
cin.tie(0); cout.tie(0);
13+
14+
cin >> N;
15+
for(int i = 0; i < N; i++){
16+
cin >> V[i];
17+
}
18+
19+
long long cnt = 1;
20+
long long ans = 1;
21+
for(int i = N - 2; i >= 0; i--){
22+
if (V[i] >= cnt + 1) cnt++;
23+
else cnt = V[i];
24+
ans += cnt;
25+
}
26+
cout << ans;
27+
return 0;
28+
}

0 commit comments

Comments
 (0)