| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 366900 | kostia244 | Garage (IOI09_garage) | C++17 | 1 ms | 492 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
#include<bits/stdc++.h>
#define all(x) begin(x), end(x)
using namespace std;
const int maxn = 2e3 + 5, C = 1;
using ll = long long;
int n, m, b[maxn], r[maxn], w[maxn], dead[maxn], crap[maxn];
ll ans = 0;
queue<int> q;
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> m;
for(int i = 1; i <= n; i++) cin >> r[i];
for(int i = 1; i <= m; i++) cin >> w[i];
for(int t, i = 0; i < 2*m; i++) {
cin >> t;
if(t > 0) {
q.push(t);
} else {t*=-1;
dead[t] = 1;
if(crap[t]) b[crap[t]] = 0;
}
while(!q.empty() && dead[q.front()]) q.pop();
if(!q.empty()) {
int fp = 1;
while(b[fp]) fp++;
if(fp <= n) {
b[fp] = 1;
crap[q.front()] = fp;
ans += r[fp]*w[q.front()];
q.pop();
}
}
}
cout << ans << '\n';
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
