-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path14.1.cpp
38 lines (36 loc) · 883 Bytes
/
14.1.cpp
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 <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <limits>
int main()
{
std::ifstream fin("test.txt");
std::string name, eater;
int speed, go, stop;
std::string winner;
int max_distance = 0;
int seconds = 2503;
while (fin >> name >> eater >> eater >> speed >> eater >> eater >> go >> eater >> eater >> eater >> eater >> eater >> eater >> stop >> eater)
{
int steps = seconds / (go + stop);
int distance = steps * speed * go;
if (steps * (go + stop) < seconds)
{
if (seconds - steps * (go + stop) < go)
distance += (seconds - steps * (go + stop)) * speed;
else
distance += speed * go;
}
if (distance > max_distance)
{
max_distance = distance;
winner = name;
}
}
std::cout << max_distance;
}