#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int N, T, K; cin >> N >> T; vector t(N - 1); for (int i = 0; i < N - 1; i++) cin >> t[i]; cin >> K; unordered_set clockLocations; for (int i = 0; i < K; i++) { int x; cin >> x; clockLocations.insert(x - 1); // Store as 0-based index } priority_queue, greater> pq; int timeLeft = T, clocksUsed = 0; for (int i = 0; i < N - 1; i++) { timeLeft -= t[i]; // Move to the next location if (timeLeft < 0) { // If time runs out before reaching cout << "-1\n"; return 0; } if (clockLocations.count(i)) pq.push(10); // Add +10 clock if available while (timeLeft < 0 && !pq.empty()) { // Use clocks greedily timeLeft += pq.top(); pq.pop(); clocksUsed++; } if (timeLeft < 0) { // If we still can't proceed, fail cout << "-1\n"; return 0; } } cout << clocksUsed << "\n"; return 0; }