| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 122945 | KieranHorgan | Garage (IOI09_garage) | C++17 | 3 ms | 380 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
// #define int long long
#define ld double
#define pii pair<int,int>
#define rand() abs((rand()<<15)|rand())
#define randll() abs(((long long)rand()<<30)|rand())
const int MOD = 1000000007;
int r[105];
int w[2005];
int taken[105];
int hasTaken[2005];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
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];
queue<int> q;
int ans = 0;
for(int t = 0; t < 2*m; t++) {
int i;
cin >> i;
if(i > 0) {
q.push(i);
int j = q.front();
for(int i = 1; i <= n; i++)
if(!taken[i]) {
taken[i] = 1;
hasTaken[j] = i;
ans += r[i] * w[j];
q.pop();
break;
}
} else {
i *= -1;
taken[hasTaken[i]] = 0;
hasTaken[i] = 0;
if(!q.empty()) {
int j = q.front();
for(int i = 1; i <= n; i++)
if(!taken[i]) {
taken[i] = 1;
hasTaken[j] = i;
ans += r[i] * w[j];
q.pop();
break;
}
}
}
}
cout << ans << endl;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
