Contest Duration: ~ (local time) (130 minutes) Back to Home

Submission #2534950

Source Code Expand

Copy
```#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

template<class T> void inputVector(vector<T>& v, int n) {
v.resize(n);
for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
int N;
cin >> N;

vector<int> A;
inputVector(A, N);

if (A[0] != 0) {
cout << -1 << endl;
return 0;
}

REP(i, 1, N - 1) {
if (A[i] > A[i - 1] && A[i] - A[i - 1] != 1) {
cout << -1 << endl;
return 0;
}
}

int ret = 0;
int prev = N;
for (int i = N - 1; i >= 0; i--) {
if (i == N - 1 || A[i] != A[i + 1] - 1) {
ret += A[i];
}
}

cout << ret << endl;

return 0;
}
```

#### Submission Info

Submission Time 2018-05-20 21:22:57+0900 C - Sequence Growing Easy iwashi31 C++14 (GCC 5.4.1) 700 1328 Byte AC 78 ms 1792 KB

#### Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt, s3.txt
All 700 / 700 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt 78 ms 1792 KB
02.txt 78 ms 1792 KB
03.txt 59 ms 1792 KB
04.txt 59 ms 1792 KB
05.txt 56 ms 1792 KB
06.txt 56 ms 1792 KB
07.txt 58 ms 1792 KB
08.txt 57 ms 1792 KB
09.txt 58 ms 1792 KB
10.txt 58 ms 1792 KB
11.txt 56 ms 1792 KB
12.txt 56 ms 1792 KB
13.txt 56 ms 1792 KB
14.txt 56 ms 1792 KB
15.txt 57 ms 1792 KB
16.txt 57 ms 1792 KB
17.txt 57 ms 1792 KB
18.txt 57 ms 1792 KB
19.txt 59 ms 1792 KB
20.txt 59 ms 1792 KB
21.txt 46 ms 1792 KB
22.txt 42 ms 1792 KB
23.txt 46 ms 1792 KB
24.txt 38 ms 1792 KB
25.txt 54 ms 1792 KB
26.txt 55 ms 1792 KB
27.txt 55 ms 1792 KB
28.txt 55 ms 1792 KB
29.txt 55 ms 1792 KB
30.txt 53 ms 1792 KB
31.txt 56 ms 1792 KB
32.txt 56 ms 1792 KB
33.txt 33 ms 1792 KB
34.txt 48 ms 1792 KB
35.txt 56 ms 1792 KB
36.txt 59 ms 1792 KB
37.txt 56 ms 1792 KB
38.txt 57 ms 1792 KB
39.txt 59 ms 1792 KB
40.txt 60 ms 1792 KB
41.txt 1 ms 256 KB
42.txt 1 ms 256 KB
43.txt 2 ms 256 KB
44.txt 1 ms 256 KB
45.txt 1 ms 256 KB
46.txt 1 ms 256 KB
s1.txt 1 ms 256 KB
s2.txt 1 ms 256 KB
s3.txt 1 ms 256 KB