https://i1.wp.com/eblogarithm.com/wp-content/uploads/2017/01/Codeforces-Round-393-Div-2-8VC-Venture-Cup-2017--Final-Round-Div-2-Edition-problem-D-Travel-Card-Solution-in-CC1.png?fit=640%2C360

Codeforces Round #393 (Div. 2) (8VC Venture Cup 2017 – Final Round Div. 2 Edition), problem: (D) Travel Card Solution in C/C++

#include <stdio.h>

#define SIZE 100010

struct ride {
int cost, t;
} r[SIZE];

int main()
{
int i, j, n;
scanf(“%d”, &n);

r[0].t = r[0].cost = 0;

for (i = 1; i <= n; i++)
{
scanf(“%d”, &r[i].t);
r[i].cost = r[i – 1].cost + 20;

for (j = i; j > 0 && (r[j].t + 90 > r[i].t); j–)
if (r[j – 1].cost + 50 < r[i].cost)
r[i].cost = r[j – 1].cost + 50;

for (j = i; j > 0 && (r[j].t + 1440 > r[i].t); j–)
if (r[j – 1].cost + 120 < r[i].cost)
r[i].cost = r[j – 1].cost + 120;

printf(” %d\n”, r[i].cost – r[i – 1].cost);
}

return 0;
}

(Visited 91 times, 1 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: