Embassy
SRM 414 · 2008-08-16 · by StevieT
Problem Statement
Constraints
- forms will contain between 1 and 50 elements, inclusive.
- Each element of forms will be between 1 and 1,000,000 (10^6), inclusive.
- dayLength will be between 1 and 1,000,000 (10^6), inclusive.
- openTime will be between 1 and dayLength, inclusive.
{4,4,4}
24
8
Returns: 12
The embassy is open for 8 hours out of a 24 hour day. Each of the three forms takes 4 hours to fill in. If you start filling in the first form 4 hours before the embassy opens, you can get it approved just as the embassy opens. The embassy will still be open 4 hours later to approve the second form and the third form can be approved just as the embassy shuts. Since you never have to wait, the total time is 12 hours.
{4,4,4,4}
24
8
Returns: 28
Now there is an additional form to fill in. You can't complete the process in a single day.
{2,2,2,2}
24
1
Returns: 73
The embassy is only open for one hour each day, so you can only get one form approved per day.
{25,500,630,2500,1000,350,22,58,100,400,500,5000}
1440
360
Returns: 16945
Time is now measured in minutes. It's optimal to start filling in the first form 335 minutes after the embassy first opens.
{567213,494175,41987,510822,279719,889559,572483,117704,641618,110895,259588,721431,930617,438350,184363,37908,784347,842509,563146,965103,966945,204978,136741,308997,814758,672822,774768,279015,303415,142975,980557,678292,354894,539685,246801,649725,110680,480112,286912,941249,157936,208727,608459,283950,983841,505666,684633,863492,84134,478601}
389114
349228
Returns: 24712086
Submissions are judged against all 136 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Embassy with a public method int visaApplication(vector<int> forms, int dayLength, int openTime) · 136 test cases · 2 s / 256 MB per case