Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void readfile()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(0);cout.tie(0);
- if (fopen(Task".inp","r"))
- {
- freopen(Task".inp","r",stdin);
- freopen(Task".out","w",stdout);
- }
- cin >> k;
- cin >> n;
- for(int i=1; i<=n; i++) cin >> a[i];
- }
- void proc()
- {
- double prev_time = 0;
- for(int i=1; i<=n; i++){
- //first i person consume prev_time
- //if i+1 can hear i lesser than prev_time
- if (a[i+1] - prev_time < a[i]+k+1e-9) a[i+1] = max(a[i]+k,a[i+1]-prev_time);
- //else i+1 must run to the left prev_time distances
- else a[i+1]-=prev_time;
- prev_time += max(0.0,(a[i+1]-a[i]-k)/2);
- a[i+1] -= max(0.0,(a[i+1]-a[i]-k)/2);
- }
- cout << setprecision(6) << fixed << prev_time;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement