# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
445042 | cpp219 | Garage (IOI09_garage) | C++14 | 2 ms | 332 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimization O2
#pragma GCC optimization "unroll-loop"
#pragma target ("avx2")
#include <bits/stdc++.h>
#define ll int
#define ld long double
#define fs first
#define sc second
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 2000 + 9;
const ll Log2 = 30;
const ll mod = 1e9 + 7;
priority_queue<ll,vector<ll>,greater<ll>> spare;
queue<ll> wait;
ll n,m,R[N],a[N],x,take[N];
int main(){
ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
#define task "tst"
if (fopen(task".INP","r")){
freopen(task".INP","r",stdin);
//freopen(task".OUT","w",stdout);
}
ll ans = 0;
cin>>n>>m;
for (ll i = 1;i <= n;i++) cin>>R[i],spare.push(i);
for (ll i = 1;i <= m;i++) cin>>a[i];
for (ll i = 1;i <= 2*m;i++){
cin>>x;
if (x > 0){
if (!spare.empty()){
ll now = spare.top(); spare.pop();
take[x] = now; ans += R[now] * a[x];
}
else wait.push(x);
}
else{
x = -x; ll now = take[x]; spare.push(now);
while (!wait.empty() && !spare.empty()){
ll place = spare.top(); spare.pop();
ll car = wait.front(); wait.pop();
ans += R[place] * a[car]; take[car] = place;
}
}
}
cout<<ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |