TEMPLELA, why using cin.ignore(max,'\n') give WA

link to the problem
Edit solution link My WA solution
Since the satisfied land is fixed according to its size (ex N = 5 → 1 2 3 2 1), I read each number, and if it doesn’t satisfy, output no and ignore the rest of the line using
cin.ignore(numeric_limits<streamsize>::max(), '\n');
But I get WA and don’t know why, thank you for any help

Edit:

While we’re waiting: I’m going to assume it’s CodeChef: Practical coding for everyone, in which case it fails this testcase:

(skipping the rest of the line after reading in the value of N just skips the line containing the value of N, not the following line containing the strip heights!).

1 Like