Why it is giving wrong answer. As my test cases are running correctly as well

Review problem - 5 (Logic Building - Getting started with java)

Assess your performance by solving these problems on your own!

There are 10 problems in a contest. You know that the score of each problem is either 1 or 100 points.

Chef came to know the total score of a participant and he is wondering how many problems were actually solved by that participant.

Given the total score P of the participant, determine the number of problems solved by the participant. Print −1 in case the score is invalid.

Input
5 103 0 6 142 1000

Output
4 0 6 -1 10

My Code

// Update the code below to solve this problem
import java.util.Scanner;

class Codechef
{
public static void main (String[] args)
{
Scanner sc = new Scanner(System.in);
int p, s=0, rem;;
int t = sc.nextInt();
for(int i=0; i<t; i++)
{
p = sc.nextInt();

		if(p>=0 && p<100){
		    if(p<=10){
		        s = p;
		    }
		    else{
		        s = -1;
		    }
		}
		else if(p>=100 && p<=1000){
		    rem = p%100;
		    s = p/100;
		    if(rem<10){
		        s = s+rem;
		    }
		    else{
		        s=-1;
		    }
		}
		else{
		    s=-1;
		}
		
		System.out.println(s);
		
		t--;
	}	
		
}
	}
t = int(input())
for i in range(t):
    P = int(input())

if P <= 10:
        print(P)
else:
     resto = P % 10 
     cociente = P // 100
            if  P % 100 > 10:
            print(-1)
        else:
            print(resto+cociente)

I also get an error and I get the correct answer :x or so i think

Yes, i was wrong

t = int(input())
for i in range(t):
    P = int(input())
    if P <= 10:
        print(P)
    else:
        resto = P % 100 
        cociente = P // 100
        if  resto + cociente <=10:
            print(resto+cociente)
        else:
            print(-1)

now it is correct :smiley: (Python)

# Update the code below to solve this problem

t = int(input())
for i in range(t):
    P = int(input())
    if((P//100+P%100)<=10):
        print((P//100+P%100))
    else:
        print(-1)