# Only 30 Marks for "Smart Phone" (ZCO14003)

I have Submitted the Code But I got only 30 Marks.
I am not able to understand what does it mean by sub tasks given in the Problem.
Problem:- https://www.codechef.com/LRNDSA01/problems/ZCO14003
included libraries: string, iostream, vector

using namespace std;
int main(){
long long temp_sum{0}, tot_rev{0}, price{0}, t;
cin>>t;
vector prices(t);

``````for(auto &price : prices)
cin>>price;

for(auto price : prices){
for(auto a : prices){
if(a >= price){
temp_sum += price;
}
}
if(temp_sum > tot_rev){ tot_rev = temp_sum; }
temp_sum = 0;
}
cout<<tot_rev;
return 0;
``````

}

Your code is too slow. You need to optimise it.

2 Likes

I know that I am using two loops which makes the time complexity O(n^2) But other peoples are using a sorting method (By using inbuilt libraries) which also results in O(n^2) then why my code is slow please explain dear, everule1

No. C++ inbuilt sort is O(n\log{n})

It means that due to slow program I am not able to pass the other test cases.
So, I have to use that inbuilt sorting logic to get 100 Marks. Please tell if I still can go with this solution by editing this one.

yes your solution is taking so much time to execute all test cases, that’s why you are getting TLE here

As you can see in the image it is not TLE error it is just about the sub tasks given.

yes you are getting partial points due to time limit exeeded ( TLE ).you should optimize your apparoach.

You’ve got a TLE on tasks 7 - 14.

https://www.codechef.com/viewsolution/31905128

Now, I get the point. Why my code is wrong thanks for making me understand.

Thanks you, Now I understand why my code was wrong.

1 Like