Computing capacitor voltage through series connected diode
The maximum voltage on the capacitor will be equal to the maximum input voltage, less the diode's voltage drop. Whenever the input voltage is more than a diode drop above the capacitor voltage, the diode conducts and charges up the capacitor further. Whenever the diode is reverse biased, no current flows.

It's worth noting that a diode's forward voltage is dependent on current: it's not a perfect 'elbow'. A diode will allow a small amount of current to flow even at very low forward voltages, and with high currents, the forward voltage will be substantially higher than the 'typical' forward voltage.

The capacitor will continuously discharge (slowly) through its parasitic series resistance, so in reality it won't remain fully charged forever.