# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
733858 | vjudge1 | Garage (IOI09_garage) | C++17 | 1 ms | 340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define F first
#define S second
#define pb push_back
using namespace std;
priority_queue<int > q;
int a[101], b[2001], s = 0, c[2001];
queue<int > Q;
void solve() {
int n, m; cin >> n >> m;
for (int i = 1; i <= n; i++) {cin >> a[i]; q.push(-i);}
for (int i = 1; i <= m; i++) {cin >> b[i];}
for (int i = 1; i <= 2 * m; i++) {
int r; cin >> r;
if (r < 0) {q.push(-c[-r]);}
if (r > 0) Q.push(r);
while (!Q.empty() && !q.empty()) {
int x = Q.front(); Q.pop();
int y = -q.top(); q.pop();
s += a[y] * b[x]; c[x] = y;
}
}
cout << s;
}
signed main(){IOS solve(); return 0;}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |