Submission #7387338


Source Code Expand

Copy
#include <bits/stdc++.h>
#define P pair<int,ll>
using namespace std;
typedef long long ll;
const int maxx=1e5+10;
int b[maxx];
int main(){
    int n; cin>>n;
    for(int i=1;i<n;i++){
        cin>>b[i];
    }
    int sum=0;
    for(int i=1;i<=n;i++){
        if(i==1) sum+=b[i];
        else if(i==n) sum+=b[n-1];
        else{
            sum+=min(b[i],b[i-1]);
        }
    }
    cout<<sum<<endl;
}

Submission Info

Submission Time
Task C - Maximal Value
User LIULIUii
Language C++14 (GCC 5.4.1)
Score 300
Code Size 423 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 15
Set Name Test Cases
Sample sample00, sample01, sample02
All handmade03, handmade04, handmade05, handmade06, handmade07, handmade08, handmade09, random10, random11, random12, random13, random14, sample00, sample01, sample02
Case Name Status Exec Time Memory
handmade03 AC 1 ms 256 KB
handmade04 AC 1 ms 256 KB
handmade05 AC 1 ms 256 KB
handmade06 AC 1 ms 256 KB
handmade07 AC 1 ms 256 KB
handmade08 AC 1 ms 256 KB
handmade09 AC 1 ms 256 KB
random10 AC 1 ms 256 KB
random11 AC 1 ms 256 KB
random12 AC 1 ms 256 KB
random13 AC 1 ms 256 KB
random14 AC 1 ms 256 KB
sample00 AC 1 ms 256 KB
sample01 AC 1 ms 256 KB
sample02 AC 1 ms 256 KB