어느때나 트램 탈 수 있어서 복잡하다 생각했는데 이거 트렘 타기로 결정했으면 트렘 속도로만 계산 하면 된다ㅋㅋㅋㅋ
아 너무 신기하고 기발했음
모든 경우 나눠서 생각했고 그렇게 어렵지는 않았다.
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define xx first
#define yy second
#define mod 1000000009
using namespace std;
using i64 = long long;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;
int main() {
int s, x1, x2, t1, t2, p, d;
scanf("%d %d %d %d %d %d %d", &s, &x1, &x2, &t1, &t2, &p, &d);
// printf("%d %d %d %d %d %d %d", s, x1, x2, t1, t2, p, d);
int walk_time = 0;
int tram_time = 0;
walk_time = abs(x2-x1)*t2;
if (x1 < p && d == 1)
{
tram_time += (s-p)*t1 + (s-x1)*t1;
d = -1;
}
else if (x1 <= p && d == -1)
{
tram_time += (p-x1)*t1;
d = -1;
}
else if (p <= x1 && d == 1)
{
tram_time += (x1 - p) * t1;
d = 1;
}
else if (p < x1 && d == -1)
{
tram_time += p*t1 + x1*t1;
d = 1;
}
if (x1 < x2 && d == 1)
tram_time += (x2-x1)*t1;
else if (x1 < x2 && d == -1)
tram_time += x1*t1 + x2*t1;
else if (x2 < x1 && d == 1)
tram_time += (s-x1)*t1 + (s-x2)*t1;
else if (x2<x1 && d == -1)
tram_time += (x1-x2)*t1;
cout << min(walk_time, tram_time);
return 0;
}
으행
'코드포스' 카테고리의 다른 글
[코드포스 Practice21] A. K-th Not Divisible by n (0) | 2020.06.06 |
---|---|
[코드포스 Practice21] 후기 (0) | 2020.06.06 |
[코드포스 Practice20] D. BerOS File Suggestion (0) | 2020.05.29 |
[코드포스 Practice19] E. Tell Your World (0) | 2020.05.23 |
[코드포스 Practice19] D. Minimize the error (0) | 2020.05.23 |