There are four exams throughout the year, and you only need to come in first for one of them (or do it in NG+).
There are two factors that come into play: your Knowledge stat and answers to exam questions. The first few days rephrase questions you heard in class, while the last day is automatic.
So, provided you know the answers (which are listed all over the internet), what knowledge rank do you need to be? Most seem to agree that for all but the first exam, you need to have rank 5, while the first exam only needs rank 4 (some suggest rank 3 makes more sense for the first exam, but I'd bet on 4).
Since knowledge is the hardest to rank up, getting this on any of the first 3 exams on a first playthrough is highly improbable, though since the last exam takes place towards the end of the game, having rank 5 knowledge seems reasonable.
Or you could just do it in NG+.
Good luck!