제출 #650748

#제출 시각아이디문제언어결과실행 시간메모리
650748Spade1Garage (IOI09_garage)C++14
100 / 100
2 ms344 KiB
#include<bits/stdc++.h> #define pii pair<int, int> #define pll pair<long long, long long> #define ll long long #define ld long double #define st first #define nd second #define pb push_back #define INF INT_MAX using namespace std; const int N = 110, M = 2020; int r[N], w[M]; int space[N]; queue<int> q; void solve() { int n, m; cin >> n >> m; for (int i = 1; i <= n; ++i) cin >> r[i]; for (int i = 1; i <= m; ++i) cin >> w[i]; int ans = 0; for (int i = 1; i <= 2*m; ++i) { int j; cin >> j; if (j > 0) { q.push(j); for (int i = 1; i <= n; ++i) { if (space[i] == 0) { space[i] = q.front(); ans += (r[i]*w[q.front()]); q.pop(); break; } } } else { for (int i = 1; i <= n; ++i) { if (space[i] == -j) { space[i] = 0; if (!q.empty()) { space[i] = q.front(); ans += (r[i]*w[q.front()]); q.pop(); } } } } } cout << ans << '\n'; } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); int t = 1; // cin >> t; while (t--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...