WICQ8 Problem - CodeChef question link and here is my code
#include<iostream>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include <string>
#include <algorithm>
using namespace std;
int t,len,i,parentalpha[26],alphavalue,tp=26;
long long ans=0;
string A,B;
int main()
{
scanf("%d\n",&t);
while(t--)
{
for(i=0;i<26;i++)
{
parentalpha[i]=0;
}
std::string str;
std::getline(cin, str);
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
cout<<str<<"\n";
len=str.length();
for(i=0;i<len;i++)
{
if(int(str[i])>=97&&int(str[i])<=122)
{
alphavalue=(str[i])-97;
parentalpha[alphavalue]+=1;
}
}
for(i=0;i<26;i++)
{
printf("%d ",parentalpha[i]);
}
cout<<"\n";
std::sort(parentalpha, parentalpha + 26);
for(i=0;i<26;i++)
{
printf("%d ",parentalpha[i]);
}
cout<<"\n";
for(i=25;i>=0;i--)
{
ans=ans+(long long)(parentalpha[i]*tp);
tp--;
}
printf("%lld\n",ans);
}
return 0;
}
dont know what i am doing wrong see the second test case :—
Good luck in the Facebook Hacker Cup this year!
my program gives values of e=4 but it should be 3 moreover the output for 2nd case onward are -ve could u help guys!!!
EDIT::: my updated code with the the mistakes i was doing removed but still i get WA here CodeChef: Practical coding for everyone CODE with test cases ::::: bvBK5U - Online C++ Compiler & Debugging Tool - Ideone.com
Still WA think cases or test file is broken