Subtasks means different constraints. Brute Force or a solution with comparatively high complexity than optimal may pass subtasks with lower constraints and will give you partial AC. You have to optimize your code to pass the Subtask 2 (in your case).
If the verdict is WA (Wrong Answer) for larger constraints you’ll have to rethink your logic and/or the data types you use. If it’s TLE (Time Limit Exceeded) , then you’ll have to come up with something faster.