I was coding questions in hackerearth and i got stuck in [Winning side problem][1]
[1]: https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/winning-side/
I have written code as follow and not able to know where i am going wrong my code doesn’t display any output:-
#include using namespace std; int main() { long t,g=0,b=0; cin >> t; long a[t]; long i,j,v; for(i=0;i> a[i]; v=a[i]; char s[v]; long num[v]; cin >> s[v]; for(j=0;j> num[j]; if(s[j]=='g') { g += num[j]; } else if(s[j]=='b') { b += num[j]; } } if(g>b) { cout << "g"<<" "<g) { cout << "b" <<" " << b-g; } } return 0; }