# I am bit confuse can someone help?

**URL:** <https://discuss.codechef.com/t/i-am-bit-confuse-can-someone-help/87320>\
**Category:** general\
**Tags:** lunch-time\
**Created:** [March 29, 2021, 5:00pm UTC](https://discuss.codechef.com/t/i-am-bit-confuse-can-someone-help/87320 "2021-03-29T17:00:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ayushaps1](https://discuss.codechef.com/user_avatar/discuss.codechef.com/ayushaps1/32/24644_2.png) [@ayushaps1](https://discuss.codechef.com/u/ayushaps1)\
**Post date:** [March 29, 2021, 5:00pm UTC](https://discuss.codechef.com/t/i-am-bit-confuse-can-someone-help/87320/1 "2021-03-29T17:00:22Z")

</div>

I tried to solve this problem : [Lunchtime | CodeChef](https://www.codechef.com/LTIME94C/problems/LUNCHTIM)

so initially I went with the Bruteforce approach  
here’s my code

```auto
#include <iostream>
using namespace std;

int main() {
	int t;
	cin>>t;
	for(int i=0;i<t;i++){
	    int n;
	    cin>>n;
	    int a[n];
	    for(int j=0;j<n;j++){
	        cin>>a[j];
	    }
	    for(int j=0;j<n;j++){
	        int count=0;
	        
	        for(int k=j-1;k>=0;k--){
	            if(a[k]>a[j]){
	                break;
	            }
	            else if(a[k]==a[j]){
	                count++;
	            }
	        }
	        
	        for(int k=j+1;k<n;k++){
	            if(a[k]>a[j]){
	                break;
	            }
	            else if(a[k]==a[j]){
	                count++;
	            }
	        }
	        
	        cout<<count<<" ";
	    }
	}
	return 0;
}

```

and It worked I got 100% score but I think that this code will exceed the time limit and also I used here int instead of long long for making an array where the value of the elements of an array could be up to 10^9 but still, this code worked. Can some please explain to me how did that happen?

---

<div class="post-metadata">

**Author:** ![ssjgz](https://discuss.codechef.com/user_avatar/discuss.codechef.com/ssjgz/32/346011_2.png) [@ssjgz](https://discuss.codechef.com/u/ssjgz)\
**Post date:** [March 29, 2021, 5:23pm UTC](https://discuss.codechef.com/t/i-am-bit-confuse-can-someone-help/87320/2 "2021-03-29T17:23:18Z")

</div>

> [@ayushaps1](#):
>
> ‘’’

To format code, use [three backticks](https://discuss.codechef.com/t/tutorial-color-format-the-code/36585), not three single quotes 🙂

---

<div class="post-metadata">

**Author:** ![ayushaps1](https://discuss.codechef.com/user_avatar/discuss.codechef.com/ayushaps1/32/24644_2.png) [@ayushaps1](https://discuss.codechef.com/u/ayushaps1)\
**Post date:** [March 29, 2021, 5:39pm UTC](https://discuss.codechef.com/t/i-am-bit-confuse-can-someone-help/87320/3 "2021-03-29T17:39:52Z")

</div>

thanks for info

---

<div class="post-metadata">

**Author:** ![cubefreak777](https://discuss.codechef.com/user_avatar/discuss.codechef.com/cubefreak777/32/215911_2.png) [@cubefreak777](https://discuss.codechef.com/u/cubefreak777)\
**Post date:** [March 29, 2021, 6:17pm UTC](https://discuss.codechef.com/t/i-am-bit-confuse-can-someone-help/87320/4 "2021-03-29T18:17:50Z")

</div>

test-cases for this problem were weak. He discussed it pretty well in this post.

> [@LUNCHTIM - Editorial](https://discuss.codechef.com/t/lunchtim-editorial/87198/28):
>
> It clearly states that Proper testing was not done on this problem before the contest started. The worst input for an O(N^2) solution is N = 10^5 and a\_i = k\ \forall\ i\isin[1, N], where k is some constant. If they had tested this input against an O(N^2) solution, there would have not been such a huge number of accepted submissions past night. It is not fair to rejudge these submissions because the contest ended. If they (organisers) had realised about it during the contest and made an announc…
