# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
600623 | 2022-07-21T06:26:48 Z | 조영욱(#8469) | JOI15_building3 (JOI15_building3) | C++14 | 107 ms | 4608 KB |
#include <bits/stdc++.h> using namespace std; int n; int arr[1000000]; int main() { scanf("%d",&n); int mnp=0; int mxp=n-1; for(int i=1;i<n;i++) { scanf("%d",&arr[i]); } int pos=0; bool flag=true; int val; for(int i=1;i<n;i++) { if (arr[i]>arr[pos]) { if (arr[i]>arr[pos]+2) { printf("0"); return 0; } if (arr[i]==arr[pos]+2) { if (!flag) { printf("0"); return 0; } flag=false; mnp=pos; mxp=i-1; val=arr[pos]+1; } pos=i; } } if (!flag) { int ret=0; for(int i=mnp;i<=mxp;i++) { if (arr[i+1]!=val) { ret++; } } printf("%d",ret); return 0; } int mx=0; long long ret=0; for(int i=1;i<n;i++) { mx=max(mx,arr[i]); ret+=mx+(i==n-1?1:0); } printf("%lld",ret); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 312 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 312 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 308 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 316 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 312 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 308 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 316 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 86 ms | 4572 KB | Output is correct |
22 | Correct | 97 ms | 4608 KB | Output is correct |
23 | Correct | 72 ms | 4544 KB | Output is correct |
24 | Correct | 105 ms | 4576 KB | Output is correct |
25 | Correct | 80 ms | 4576 KB | Output is correct |
26 | Correct | 82 ms | 4528 KB | Output is correct |
27 | Correct | 87 ms | 4516 KB | Output is correct |
28 | Correct | 80 ms | 4584 KB | Output is correct |
29 | Correct | 66 ms | 4488 KB | Output is correct |
30 | Correct | 86 ms | 4524 KB | Output is correct |
31 | Correct | 98 ms | 4584 KB | Output is correct |
32 | Correct | 77 ms | 4472 KB | Output is correct |
33 | Correct | 107 ms | 4516 KB | Output is correct |
34 | Correct | 104 ms | 4556 KB | Output is correct |
35 | Correct | 80 ms | 4564 KB | Output is correct |