added successful solutions for ac1 in java and cpp