Sad and bittersweet endings have been part of Japanese literature, not just in anime and manga. Bittersweet ending is half-happy, half-sad, It is where you can never gain something without losing another thing.
An example would be - 5 Centimeters Per Second.