# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
733858 |
2023-05-01T11:16:38 Z |
vjudge1 |
Garage (IOI09_garage) |
C++17 |
|
1 ms |
340 KB |
#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 |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
324 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
324 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
320 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |