Submission #2376567


Source Code Expand

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#include<queue>
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 20123
#define inf 123456789
#define LL long long
#define big 1e18
using  namespace std;
int max(int a,int b){ return a>b?a:b;}
int maxn (int a,int b,int c){return max(max(a,b),max(b,c));}
LL min(LL a,LL b){return a<b?a:b;}
LL minn,a[200005],pre[200005],sum1=0;
LL dfs(LL l,LL r)
{
    if(r-l<1){
        minn=min(a[l],min(minn,a[r]));
        sum1+=minn;
    }
    else {
        LL mid=(r+l)/2;
        dfs(mid+1,r);
        dfs(l,mid);
    }
}
int main()
{
    LL n,i,j;
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    for(i=n;i>0;i--)
    {
         minn=big;
         sum1=0;
         dfs(1,i);
         pre[i]=sum1;
    }
    LL sum=0;
    for(i=1;i<=n;i++)
        sum+=pre[i];
    printf("%lld\n",sum);
    return 0;
}

Submission Info

Submission Time
Task B - Minimum Sum
User luogu_bot2
Language C++ (GCC 5.4.1)
Score 0
Code Size 962 Byte
Status TLE
Exec Time 2103 ms
Memory 1792 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:32:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
                     ^
./Main.cpp:34:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&a[i]);
                            ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 7
TLE × 6
Set Name Test Cases
Sample example0, example1, example2
All corner0, corner1, corner2, corner3, example0, example1, example2, maxrand0, maxrand1, maxrand2, rand0, rand1, rand2
Case Name Status Exec Time Memory
corner0 TLE 2103 ms 1792 KB
corner1 TLE 2103 ms 1792 KB
corner2 AC 1 ms 256 KB
corner3 TLE 2103 ms 1792 KB
example0 AC 1 ms 256 KB
example1 AC 1 ms 256 KB
example2 AC 1 ms 256 KB
maxrand0 TLE 2103 ms 1792 KB
maxrand1 TLE 2103 ms 1792 KB
maxrand2 TLE 2103 ms 1792 KB
rand0 AC 1 ms 256 KB
rand1 AC 1 ms 256 KB
rand2 AC 1 ms 256 KB