Submission #600602

# Submission time Handle Problem Language Result Execution time Memory
600602 2022-07-21T06:08:30 Z 장태환(#8468) JOI15_building3 (JOI15_building3) C++14
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
int dp[1000100][2];
int ma[1000100];
vector<int>x;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >>N;
    int i;
    for(i=1;i<N;i++)
    {
        int a;
        cin >>a;
        x.push_back(a);
    }
    x.push_back(0);
    if(x[0]!=1)
        dp[1][0]=1;
    int ma=x[0];
    for(i=2;i<=N;i++)
    {
        dp[i][0]=dp[i-1][0]+ma-(i!=N);
        dp[i][1]=1;
        if(x[i-1]>ma)
        {
            ma=x[i-1];
            dp[i][0]+=dp[i-1][1];
        }
        else
        {
            dp[i][1]+=dp[i-1][1];
        }
    }
    cout <<dp[N][0]+dp[N][1];
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -