#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
vector<int> v;
while (1)
{
int s;
cin >> s;
v.push_back(s);
char c = getchar();
if (c != ' ')
{
break;
}
}
for (int i = 0; i < v.size(); i++)
{
if (v[i] == (v.size() - 1))
{
v[i] = 0;
}
}
sort(v.begin(), v.end());
cout << v[v.size() - 1] << "\n";
}
return 0;
}
Your Formatted code… I don’t exactly know what are you trying to do… but i think the question would be like… to take inputs for every test case and find the maximum among them or something like that… i don’t know how your while(1) loop will terminate…because it may go into infinite loops or maybe it always wait for input causing runtime or TLE…
As @ssjgz said please provide the question as well as submission link don’t just copy paste raw ugly code…
but can you pls tell me why my code was not right as the output was same as given in the sample input/outputs of the original question, thanks for editing the submitted code.