Codechef lunchtime problem ARRP

Правка en2, от priyanka_1998, 2018-04-04 16:14:58

Problem link : https://www.codechef.com/LTIME58B/problems/ARRP Solution link : https://www.codechef.com/viewsolution/18034419

int main(){

ll t;
cin>>t;

while(t--){

    ll n;
    cin>>n;

    ll a[n];

    for(ll i=1;i<=n;i++)
       cin>>a[i];

    ll prefix[n];


    prefix[1]=a[1];

    for(ll i=2;i<=n;i++)
       prefix[i]=prefix[i-1]+a[i];

    ll sum=prefix[n];



    cout<<"1";

    for(ll i=2;i<=n;i++){

       ll flag=0;

       if(sum%i==0){

         flag=1;

         ll k=sum/i;
         ll p=k;

         for(ll j=1;j<=n;j++){

          if(prefix[j]==p)
              p=p+k;
          else if(prefix[j]>p){
              flag=0;
              break;
          }

         }          
       }

       if(flag)
         cout<<"1";
       else
         cout<<"0";

    }

    cout<<"\n";



}


return 0;

}

can anyone help me to compute the time complexity of my code . It got accepted How??

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский priyanka_1998 2018-04-04 16:14:58 946
en1 Английский priyanka_1998 2018-04-04 16:13:16 1839 Initial revision (published)