# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
733858 | vjudge1 | Garage (IOI09_garage) | C++17 | 1 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |