#include <iostream>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

class Event{
public:
	int time, group, type;
	Event(int t, int g, int p) : time(t), group(g), type(p) {}
	bool operator < (const Event &e) const { return make_pair(time,type) > make_pair(e.time,e.type); }
};

int main(){
	int n, m, t;
	int c[100], pos[10000], T[10000], P[10000], W[10000], E[10000];
	int seat[100][100];
	int left[100], right[100], seq[100];
	bool out[10000], in[10000];
	double score[10000];
	while(cin >> n >> m >> t, n){
		for(int i=0;i<n;i++) cin >> c[i];
		memset(pos, -1, sizeof(pos));
		memset(out,false,sizeof(out));
		memset(in, false,sizeof(in));
		memset(seat, -1, sizeof(seat));
		priority_queue<Event> qu;
		queue<int> wait;
		for(int i=0;i<m;i++){
			cin >> T[i] >> P[i] >> W[i] >> E[i];
			qu.push(Event(T[i],i,1));
			qu.push(Event(T[i]+W[i],i,3));
		}
		while(!qu.empty()){
			Event e = qu.top(); qu.pop();
			if(e.type == 0){
				for(int i=0;i<c[pos[e.group]];i++){
					if(seat[pos[e.group]][i] == e.group) seat[pos[e.group]][i] = -1;
				}
				if(e.time<t) qu.push(Event(e.time,-1,2));
			}
			if(e.type == 1){
				while(!wait.empty()&&out[wait.front()]){ wait.pop(); }
				if(wait.empty()){
					int idxA = -1, idxB = -1, mScore = -1, MScore = -1;
					for(int i=0;i<n;i++){
						if(c[i] < P[e.group]) continue;
						left[0] = seat[i][0]==-1 ? 10000 : -1;
						for(int j=1;j<c[i];j++){
							if(seat[i][j]!=-1) left[j] = -1;
							else if(left[j-1]==10000) left[j] = 10000;
							else left[j] = left[j-1]+1;
						}
						right[c[i]-1] = seat[i][c[i]-1]==-1 ? 10000 : -1;
						for(int j=c[i]-2;j>=0;j--){
							if(seat[i][j]!=-1) right[j] = -1;
							else if(right[j+1]==10000) right[j] = 10000;
							else right[j] = right[j+1]+1;
						}
						for(int j=0;j<c[i];j++){
							if(seat[i][j]!=-1) seq[j] = -1;
							else if(j==0) seq[j] = 0;
							else seq[j] = seq[j-1]+1;
						}
						for(int j=0;j+P[e.group]-1<c[i];j++){
							if(left[j]!=-1&&seq[j]+P[e.group]-1==seq[j+P[e.group]-1]){
								if(idxA == -1||make_pair(mScore,MScore)<make_pair(min(left[j],right[j+P[e.group]-1]),max(left[j],right[j+P[e.group]-1]))){
									idxA = i; 
									idxB = j; 
									mScore = min(left[j],right[j+P[e.group]-1]);
									MScore = max(left[j],right[j+P[e.group]-1]);
								}
							}
						}
					}
					if(idxA == -1) { wait.push(e.group); continue; }
					for(int i=0;i<P[e.group];i++) seat[idxA][idxB+i] = e.group;
					pos[e.group] = idxA;
					in[e.group] = true;
					score[e.group] = 1.0;
					qu.push(Event(e.time+E[e.group], e.group, 0));
				} else {
					wait.push(e.group);
				}
			}
			if(e.type == 2){
				while(!wait.empty()){
					if(out[wait.front()]){ wait.pop(); continue; }
					int group = wait.front();
					int idxA = -1, idxB = -1, mScore = -1, MScore = -1;
					for(int i=0;i<n;i++){
						if(c[i] < P[group]) continue;
						left[0] = seat[i][0]==-1 ? 10000 : -1;
						for(int j=1;j<c[i];j++){
							if(seat[i][j]!=-1) left[j] = -1;
							else if(left[j-1]==10000) left[j] = 10000;
							else left[j] = left[j-1]+1;
						}
						right[c[i]-1] = seat[i][c[i]-1]==-1 ? 10000 : -1;
						for(int j=c[i]-2;j>=0;j--){
							if(seat[i][j]!=-1) right[j] = -1;
							else if(right[j+1]==10000) right[j] = 10000;
							else right[j] = right[j+1]+1;
						}
						for(int j=0;j<c[i];j++){
							if(seat[i][j]!=-1) seq[j] = -1;
							else if(j==0) seq[j] = 0;
							else seq[j] = seq[j-1]+1;
						}
						for(int j=0;j+P[group]-1<c[i];j++){
							if(left[j]!=-1&&seq[j]+P[group]-1==seq[j+P[group]-1]){
								if(idxA == -1||make_pair(mScore,MScore)<make_pair(min(left[j],right[j+P[group]-1]),max(left[j],right[j+P[group]-1]))){
									idxA = i; 
									idxB = j; 
									mScore = min(left[j],right[j+P[group]-1]);
									MScore = max(left[j],right[j+P[group]-1]);
								}
							}
						}
					}
					if(idxA == -1) break;
					for(int i=0;i<P[group];i++) seat[idxA][idxB+i] = group;
					pos[group] = idxA;

					in[group] = true;
					score[group] = (T[group]+W[group]-e.time)/(double)W[group];
					qu.push(Event(e.time+E[group], group, 0));
					wait.pop();
				}
			}
			if(e.type == 3){
				if(in[e.group] == true) continue;
				out[e.group] = true;
				score[e.group] = -1.0;
				if(e.time<t) qu.push(Event(e.time,-1,2));
			}
		}
		double ans = 0.0;
		int sum = 0;
		for(int i=0;i<m;i++){
			ans += score[i]*P[i];
			sum += P[i];
		}
		printf("%.10lf\n", ans/sum);
	}
}

Measured memory_bytes: 1904