CORUS - Editorial

i have executed your code this is the output of your code

@vijju532
Thanks:)

@kxp3 A loop from 0 to c will give a TLE error.

1 Like

yes , got that

can u say about this code. what’s wrong in this code?
https://www.codechef.com/viewsolution/33066338
https://www.codechef.com/viewsolution/33066628

You have declared dictionary outside test case loop … and u never updated its value to zero for test cases…

why i am not getting 100 points ?
#include
using namespace std;

int main() {
long long int t;
cin>>t;
while(t–)
{
unsigned long long int n,q,i,j,k,count=0;
cin>>n>>q;
string s,a;
cin>>s;
int aru=q;
long long int c[aru],sum[aru];
unsigned const int m=1000000007;
for(i=0;i<aru;i++)
{
cin>>c[i];
}
for(i=0;i<aru;i++)
{
sum[i]=0;
a=s;
for(j=0;j<a.length();j++)
{
if(a[j]!=0){
count++;
for(k=j+1;k<a.length();k++)
{
if(a[k]==a[j]&&a[k]!=0)
{
count++;
a[k]=0;
}
}}
if(count>c[i]&&a[j]!=0)
{
sum[i]=sum[i]+count-c[i];
}
a[j]=0;
count=0;
}
sum[i]=sum[i]%m;
cout<<sum[i]<<endl;
}
}
}

Simple Explanation:

Get the frequency of all characters in the string in an array.

Sort the array

while (frequency[i]-isoCentersCount>0 && i>0) 
{
    answer+=frequency[i]-isoCentersCount;
    i--;
}

@arpityadav12. Your code fails due to time constraints. Your code runs nearly in O(N * N) which gave TLE error.

Hey Can Someone help in my code its giving me WA but Sample Test Passes.
https://www.codechef.com/viewsolution/33153131

@sid15298, a case for which your code fails:

1
4 1
zzbh
1

Your o/p:
2

Expected o/p:
1

i tried to do the same problem
my approach is quite different
please look into it and tell my mistake As my code is giving correct output but while submitting it shows RE,please look into it
Link to my code: :: CodeChef: Practical coding for everyone

what’s wrong with my code , it gave wrong answer but test cases pass.
Link to my solution CodeChef: Practical coding for everyone

@rachit_1234567, your code fails for
i/p:
1
1 1
a
0

your o/p:
0

expected o/p:
1

Thank you so much , i got my mistake …

I dont know whats wrong with my code: CodeChef: Practical coding for everyone ?

@aitchdeecee, your code fails for
i/p:
1
1 1
a
10

your o/p:
a
0

expected o/p:
0