Submission #13740276


Source Code Expand

/* ********************************* JAI SAI RAM ************************************* */
//kash E C SE pahle dekha hota 
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl "\n"
ll P=1000000007;
ll a[200001],suffix[200001];
bool is_it_possible(ll level)
{
    ll tot=suffix[level];
    ll i=level;
    ll curr=tot;
    while(i>0)
    {
        i--;
        curr=(curr+1)/2+a[i];
    }
    if(curr<=1)
    return true;
    else 
    return false;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i,j,k,l,m,n,o,p,q,r,t,h1,m1,h2,m2,start,end,mid;
    cin>>n;
    for(i=0;i<=n;i++)
    cin>>a[i];
    suffix[n+1]=0;
    for(i=n;i>=0;i--)
    {
       suffix[i]=a[i]+suffix[i+1];
    }
    start=0;
    ll index=-1;
    end=n;
    while(start<=end)
    {
         mid=(start+end)/2;//saturate above this 
        if(is_it_possible(mid))
        {
            index=mid;
            end=mid-1;
        }
        else 
        {
            start=mid+1;
        }
    }
    if(index==-1)
    {
        cout<<"-1\n";
        return 0;
    }
    ll ans=0;
    for(i=index;i<=n;i++)
    ans+=suffix[i];
    i=index;
    ll curr=suffix[index];
    while(i>0)
    {
        i--;
        curr=(curr+1)/2+a[i];
        ans+=curr;
    }
    cout<<ans<<endl;
    return 0;
}

Submission Info

Submission Time
Task C - Folia
User AM_I_Learning
Language C++ (GCC 9.2.1)
Score 0
Code Size 1390 Byte
Status WA
Exec Time 20 ms
Memory 5200 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:28:10: warning: unused variable ‘j’ [-Wunused-variable]
   28 |     ll i,j,k,l,m,n,o,p,q,r,t,h1,m1,h2,m2,start,end,mid;
      |          ^
./Main.cpp:28:12: warning: unused variable ‘k’ [-Wunused-variable]
   28 |     ll i,j,k,l,m,n,o,p,q,r,t,h1,m1,h2,m2,start,end,mid;
      |            ^
./Main.cpp:28:14: warning: unused variable ‘l’ [-Wunused-variable]
   28 |     ll i,j,k,l,m,n,o,p,q,r,t,h1,m1,h2,m2,start,end,mid;
      |              ^
./Main.cpp:28:16: warning: unused variable ‘m’ [-Wunused-variable]
   28 |     ll i,j,k,l,m,n,o,p,q,r,t,h1,m1,h2,m2,start,end,mid;
      |                ^
./Main.cpp:28:20: warning: unused variable ‘o’ [-Wunused-variable]
   28 |     ll i,j,k,l,m,n,o,p,q,r,t,h1,m1,h2,m2,start,end,mid;
      |                    ^
./Main.cpp:28:22: warning: unused variable ‘p’ [-Wunused-variable]
   28 |     ll i,j,k,l,m,n,o,p,q,r,t,h1,m1,h2,m2,start,end,mid;
      |                      ^
./Main.cpp:28:24: warning: unused variable ‘q’ [-Wunused-variable]
   28 |     ll i,j,k,l,m,n,o,p,q,r,t,h1,m1,h2,m2,start,end,mid;
      |                        ^
./Main.cpp:28:26: warning: unused variable ‘r’ [-Wunused-variable]
   28 |     ll i,j,k,l,m,n,o,p,q,r,t,h1,m1,h2,m2,start,end,mid;
      |                          ^
./Main.cpp:28:28: warning: unused variable ‘t’ [-Wunused-variable]
   28 |     ll i,j,k,l,m,n,o,p,q,r,t,h1,m1,h2,m2,start,end,mid;
      |                            ^
./Main.cpp:28:30: warning: unused variable ‘h1’ [-Wunused-variable]
   28 |     ll i,j,k,l,m,n,o,p,q,r,t,h1,m1,h2,m2,start,end,mid;
      |                              ^~
./Main.cpp:28:33: warning: unused variable ‘m1’ [-Wunused-variable]
   28 |     ll i,j,k,l,m,n,o,p,q,r,t,h1,m1,h2,m2,start,end,mid;
      |                                 ^~
./Main.cpp:28:36: warning: unused variable ‘h2’ [-Wunused-variable]
   28 |     ll i,j,k,l,m,n,o,p,q,r,t,h1,m1,h2,m2,start,end,mid;
      |                                    ^~
....

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 5
AC × 29
WA × 12
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt, s4.txt, s5.txt
All 0.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 3.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, s1.txt, s2.txt, s3.txt, s4.txt, s5.txt
Case Name Status Exec Time Memory
0.txt WA 12 ms 4576 KiB
1.txt AC 9 ms 4300 KiB
10.txt AC 4 ms 3916 KiB
11.txt AC 14 ms 4492 KiB
12.txt AC 8 ms 3956 KiB
13.txt AC 6 ms 4476 KiB
14.txt WA 17 ms 4900 KiB
15.txt WA 15 ms 5092 KiB
16.txt WA 15 ms 5164 KiB
17.txt WA 20 ms 5032 KiB
18.txt WA 15 ms 5068 KiB
19.txt WA 15 ms 5200 KiB
2.txt AC 7 ms 3940 KiB
20.txt WA 15 ms 5096 KiB
21.txt WA 14 ms 5124 KiB
22.txt AC 19 ms 5168 KiB
23.txt AC 12 ms 4360 KiB
24.txt AC 15 ms 4668 KiB
25.txt AC 6 ms 4264 KiB
26.txt AC 3 ms 3700 KiB
27.txt AC 6 ms 4192 KiB
28.txt AC 19 ms 5036 KiB
29.txt AC 16 ms 4892 KiB
3.txt AC 2 ms 3644 KiB
30.txt AC 2 ms 3596 KiB
31.txt AC 1 ms 3504 KiB
32.txt AC 2 ms 3552 KiB
33.txt AC 2 ms 3596 KiB
34.txt AC 3 ms 3748 KiB
35.txt AC 7 ms 4120 KiB
4.txt WA 5 ms 3956 KiB
5.txt AC 7 ms 4052 KiB
6.txt WA 4 ms 3856 KiB
7.txt WA 11 ms 4568 KiB
8.txt AC 3 ms 3768 KiB
9.txt AC 12 ms 4516 KiB
s1.txt AC 2 ms 3588 KiB
s2.txt AC 2 ms 3512 KiB
s3.txt AC 2 ms 3528 KiB
s4.txt AC 2 ms 3532 KiB
s5.txt AC 2 ms 3528 KiB