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
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
// C5 - Butelki
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <unordered_map>
using namespace std;

struct Car {
	long long startPos;
	long long length;
	int lane;
	
	Car(long long sp, long long l, int v) {
		startPos = sp;
		length = l;
		lane = v;
	}	
};		

int main() {
	int l, prev;
	double v0, v1, v2, v3;
	char c;
	double result, candidate;
	vector<Car> carsA, carsB, carsC;
	
	cin >> l;
	cin >> v0;
	cin >> v1;
	cin >> v2;
	cin >> v3;
	
	prev = -1;
	for (int i = 0; i < l; ++i) {
		cin >> c;
//		cout << i << ": " << prev << endl;
		if (c != '#') {
			if (prev != i - 1) {
				carsA.push_back(Car(prev + 1, i - prev - 1, 0));
			}
			prev = i;
		} else if (i == l - 1) {
			carsA.push_back(Car(prev + 1, i - prev, 0));
		}			
	}
	
	prev = -1;
	for (int i = 0; i < l; ++i) {
		cin >> c;
		if (c != '#') {
			if (prev != i - 1) {
				carsB.push_back(Car(prev + 1, i - prev - 1, 1));
			}
			prev = i;
		} else if (i == l - 1) {
			carsB.push_back(Car(prev + 1, i - prev, 1));
		}			
	}
	
	prev = -1;
	for (int i = 0; i < l; ++i) {
		cin >> c;
		if (c != '#') {
			if (prev != i - 1) {
				carsC.push_back(Car(prev + 1, i - prev - 1, 2));
			}
			prev = i;
		} else if (i == l - 1) {
			carsC.push_back(Car(prev + 1, i - prev, 2));
		}			
	}
	
/*	for (unsigned i = 0; i < carsA.size(); ++i) {
		cout << "CAR A: " << carsA[i].startPos << ", " << carsA[i].length << endl;
	}
	for (unsigned i = 0; i < carsB.size(); ++i) {
		cout << "CAR B: " << carsB[i].startPos << ", " << carsB[i].length << endl;
	}
	for (unsigned i = 0; i < carsC.size(); ++i) {
		cout << "CAR C: " << carsC[i].startPos << ", " << carsC[i].length << endl;
	}*/
	
	result = -1;
	if (carsA.size() > 0) {
		candidate = (carsA[carsA.size() - 1].startPos + carsA[carsA.size() - 1].length + 1) / (v0 - v1);
		if (result < 0 || result > candidate) {
			result = candidate;
		}
	}
	if (carsB.size() > 0) {
		candidate = (carsB[carsB.size() - 1].startPos + carsB[carsB.size() - 1].length + 1) / (v0 - v2);
		if (result < 0 || result > candidate) {
			result = candidate;
		}
	}
	if (carsC.size() > 0) {
		candidate = (carsC[carsC.size() - 1].startPos + carsC[carsC.size() - 1].length + 1) / (v0 - v3);
		if (result < 0 || result > candidate) {
			result = candidate;
		}
	}
	cout << result;
	
	return 0;
}