We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0c9b7f8 commit 3b02976Copy full SHA for 3b02976
1 file changed
박예진/3주차/260113.cpp
@@ -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