Runtime Error (CFRTEST)

problem link:


solution link:
https://www.codechef.com/viewsolution/30212450

where i am wrong i am getting the required answer, but while submiting it shows run time error.

Please put the correct submission link

1 Like

Thats given naa. It is the link of my code of that particular problem.

There is quite a bit to fix, first off, the number of testcases can be 10000, whereas your array only stores 50. You can’t go forward and subtract 1 for each occurence as for example
1 2 1 1 3
You’ll subtract 2 when you see the first ‘1’ and one on the second ‘1’. So you subtract three instead of 2.
The submission link is not given. Click the number next to the verdict, and copy that link.

1 Like

okk Array size can be problematic.
But in 1 2 1 1 3 it will subtract 2 not 3 because when first 1 encountered with 2nd and 3 rd 1 the values there become 101 and 102. As you can see i have used an extra variable any
which will set 101 and 102 at 2nd and 3rd one respectively.
I suggest plz go through it just once. you can run it by putting your test cases. it will give the required answer.

@everule1
now i have changes the array size now plz can you see where i am lagging.
link: https://www.codechef.com/viewsolution/30213617

Take a guess

for(int i;i<num[z];i++){
	    cin>>arr[z][i];
	}

@everule1
:smile: :sweat_smile: :crazy_face: thanks

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        
    }
    
}

Solve for each test case inside the while loop. You overcomplicated the question.