A boutique's inventory team runs a seasonal spotlight: for a chosen date window they want to know which catalog items were sold only during that window and never before or after it, so they can flag them as true seasonal exclusives.
Line 1: two integers P and S — the number of catalog items and the number of recorded sales.
Next P lines: each contains an integer product_id and a string product_name (a single token of letters and digits, 1–30 characters), describing one catalog item. Product ids are distinct.
Next S lines: each contains an integer product_id (referring to one of the items above) and a string sale_date in YYYY-MM-DD format, describing one recorded sale of that item.
Last line: two strings start_date and end_date, both in YYYY-MM-DD format, with start_date <= end_date, describing the inclusive spotlight window.
Print one line per catalog item that was sold at least once and every one of whose recorded sales falls within [start_date, end_date] inclusive, formatted as <product_id> <product_name>. Sort the lines by product name ascending, breaking ties by product_id ascending. If no item qualifies, print a single line containing NONE.
Example 1
Input
2 4 1 Lumen 2 Aurora 1 2019-01-10 1 2019-02-15 2 2019-01-05 2 2019-06-20 2019-01-01 2019-03-29
Expected
1 Lumen
Explanation
Item 1 (Lumen) sold on 2019-01-10 and 2019-02-15, both inside the window 2019-01-01 to 2019-03-29, so it qualifies. Item 2 (Aurora) sold once inside the window (2019-01-05) but also once on 2019-06-20, which falls outside it, so Aurora is excluded. Only Lumen is printed.
Example 2
Input
2 3 1 Lumen 2 Aurora 1 2019-04-01 2 2019-02-01 2 2019-05-01 2019-01-01 2019-03-29
Expected
NONE
Explanation
Lumen's only sale (2019-04-01) falls after the window, so it does not qualify. Aurora has one sale inside the window (2019-02-01) but another outside it (2019-05-01), so it also fails the 'every sale inside the window' requirement. No item qualifies, so the program prints NONE.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →