|
@@ -0,0 +1,42 @@
|
|
|
+#include<bits/stdc++.h>
|
|
|
+using namespace std;
|
|
|
+const int maxn = 1e5 + 5;
|
|
|
+int f[maxn];
|
|
|
+int main()
|
|
|
+{
|
|
|
+ int s, x1, x2;
|
|
|
+ int t1, t2;
|
|
|
+ int p, d;
|
|
|
+ cin >> s >> x1 >> x2 >> t1 >> t2 >> p >> d;
|
|
|
+ int ans = abs(x2 - x1) * t2;
|
|
|
+ int to = x2 - x1;
|
|
|
+ if(to < 0) to = -1;
|
|
|
+ else to = 1;
|
|
|
+ if(to == 1)
|
|
|
+ {
|
|
|
+ if(d == 1)
|
|
|
+ {
|
|
|
+ if(p <= x1) ans = min((x2 - p) * t1, ans);
|
|
|
+ else ans = min((s - p + s + x2) * t1, ans);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ans = min(ans, (p + x2) * t1);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(d == -1)
|
|
|
+ {
|
|
|
+ if(p >= x1) ans = min((p - x2) * t1, ans);
|
|
|
+ else ans = min((p + s + s - x2) * t1,ans);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ans = min(ans, (s - p + s - x2) * t1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cout << ans << endl;
|
|
|
+ return 0;
|
|
|
+}
|