-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontest-10232.cpp
More file actions
38 lines (34 loc) · 806 Bytes
/
contest-10232.cpp
File metadata and controls
38 lines (34 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int n, l, t = 0, d = 0;
cin >> n >> l;
vector<int> lights_distance;
vector<pair<int, int>> lights_cycles;
while (n--)
{
int di, ri, gi;
cin >> di >> ri >> gi;
lights_distance.push_back(di);
lights_cycles.emplace_back(ri, gi);
}
for (int i = 0; i < lights_distance.size(); ++i)
{
t += (lights_distance[i] - d);
d = lights_distance[i];
int period = lights_cycles[i].first + lights_cycles[i].second;
int curent = t % period;
if (curent < lights_cycles[i].first)
{
t += lights_cycles[i].first - curent;
}
}
if (d != l)
{
t += l - d;
}
cout << t << endl;
return 0;
}