// pinball.cpp : Defines the entry point for the console application. // #include #include #include #include #include using namespace std; const int MAX = 100001; struct bar { int L, R; bool dir; }; int W[MAX], C[MAX]; int main(int argc, char* argv[]) { fstream fin, fout; fin.open("machine.in", ios::in); fout.open("machine.out", ios::out); int N, M, P, K; map< int, vector > bars; set rowsset; list rowslist; fin >> N >> M; fin >> P; for (int i = 0; i < P; i++) { int r, y; bar b; fin >> y >> b.L >> b.R >> r; b.dir = r == 1; bars[y].push_back(b); rowsset.insert(y); } rowslist.assign(rowsset.begin(), rowsset.end()); rowslist.sort(); for (int i = 0; i < M; i++) { fin >> W[i]; } fin >> K; for (int i = 0; i < K; i++) { fin >> C[i]; } long long total = 0; for (int i = 0; i < K; i++) { int x = C[i]; for (auto ity(rowslist.begin()), end(rowslist.end()); ity != end; ity++) { int y = *ity; auto itb = bars.find(y); if (itb != bars.end()) { vector& bsy = itb->second; for (int p = 0, pc = bsy.size(); p < pc; p++) { bar& b = bsy[p]; if (b.L >= x && x <= b.R) { if (b.dir) { x = b.R + 1; } else { x = b.L - 1; } b.dir = !b.dir; break; } } } } total += W[x - 1]; } fout << total << endl; return 0; }