# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
600619 | 2022-07-21T06:24:54 Z | 조영욱(#8469) | JOI15_building3 (JOI15_building3) | C++14 | 1 ms | 212 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||!flag) { printf("0"); return 0; } if (arr[i]==arr[pos]+2) { 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 | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Incorrect | 1 ms | 212 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | 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 | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Incorrect | 1 ms | 212 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | 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 | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Incorrect | 1 ms | 212 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |