SVAREA11 - Save Area 11
In the year 2010 of the Imperial Calendar, the Holy Britannian Empire invaded Japan and overpowered the defending forces. Japan became a dominion of the Empire. The country was stripped off her freedom, her rights and her name. The defeated and once proud nation was given a mere number as a name - Area 11.
After many years, Lelouch vi Britannia, the leader of the Black Knights, is making plans for some important battles against the Holy Britannian Empire army in his quest to free Area 11. He is assigning soldiers of the Black Knights to various strategically advantageous positions on the battlefields.
Lelouch assigns a soldier to a position from T1 second to T2 second. The soldier leaves to fight at the beginning of T1 second and returns at the end of T2 second. During this time, this soldier is unavailable for any other assignments. After returning, he is available for future assignments. A complete plan includes several of these assignments.
The Black Knights does not have unlimited number of soldiers. Lelouch has made plans for several battles and now he is trying to distribute his soldiers to carry out these plans. He takes a plan and allocates N soldiers for it. Then he asks you to check if the plan can be carried out successfully with N soldiers.
Help Lelouch make the plans. The fate of Area 11 depends on you!
Input begins with an integer P (1 ≤ P ≤ 105), indicating the number of plans. Then follows the P plans. Each plan begins with two integers N (0 ≤ N ≤ 109) and A (0 ≤ A ≤ 104), indicating the number of soldiers allocated for that plan and the number of assignments that plan has respectively. The next A lines each contains two integers S and E (1 ≤ S ≤ E ≤ 104), indicating the starting and the ending time of an assignment.
For each plan, print a single line in the format Plan X: Y, where X is the plan number and Y is either Yes or No, indicating whether the plan can be completed successfully or not.
1 41 2 Output:
Plan 1: YesPlan 2: No
Note: Dataset is huge. Use faster I/O method.
Why is my code giving NZEC error
@imranziad any suggestion to avoid tle?
Remember soldier returns at the end of T2Last edit: 2020-02-13 17:04:59
I am getting TLE for O(aloga) solution. Is there a better way??Last edit: 2017-05-27 16:45:56
All hail Lelouch! All hail Britannia!!!
@imranziad, Can u check my solution plz?
[BITMEN] DARK LORD:
thanks @imranziad for the test case..Finally AC :D
[BITMEN] DARK LORD:
don't know why getting wrong answer.although is showing correct for all test cases i can think off..