# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
152323 | miello | Garage (IOI09_garage) | C++11 | 3 ms | 380 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define mkp make_pair
#define pb push_back
#define emb emplace_back
#define em emplace
#define ii pair<int,int>
#define iii pair<int ,ii>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define allc(x) x.begin(),x.end(),cmp
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int INF = 0x3f3f3f3f;
const int MXN = 2005;
int cost[MXN] , w[MXN] , l[MXN];
bool chk[MXN];
queue<int> q;
int main(){
int n , m;
scanf("%d %d",&n,&m);
for(int i = 1 ; i <= n ; i++){
scanf("%d",&cost[i]);
}
for(int i = 1 ; i <= m ; i++){
scanf("%d",&w[i]);
}
int ans = 0;
for(int i = 0 ; i < 2 * m ; i++){
int x;
scanf("%d",&x);
if(x < 0){
x = abs(x);
// printf("%d %d %d\n",x,cost[l[x]] , l[x]);
ans += cost[l[x]] * w[x];
chk[l[x]] = 0;
if(q.size()){
int u = q.front();
chk[l[x]] = 1;
l[u] = l[x];
q.pop();
}
}else{
bool non = 0;
for(int j = 1 ; j <= n ; j++){
if(!chk[j]){
non = 1;
chk[j] = 1;
l[x] = j;
break;
}
}
if(!non){
q.push(x);
}
}
}
printf("%d",ans);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |