Lift generation with optimal elastic pitching for a flapping plate