# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
980844 | LOLOLO | Garage (IOI09_garage) | C++14 | 2 ms | 456 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int N, M;
int R[101010];
int W[101010]; //R*W
int pos[101010];
queue<int> Q;
int main()
{
scanf("%d%d", &N, &M);
for(int i=1; i<=N; ++i)
scanf("%d", R+i);
for(int i=1; i<=M; ++i)
scanf("%d", W+i);
int ans = 0;
for(int i=0; i<2*M; ++i)
{
int t; scanf("%d", &t);
if(t>0)
Q.push(t);
else
{
for(int i=1; i<=N; ++i)
if(pos[i] == -t) pos[i] = 0;
}
for(int i=1; i<=N; ++i)
{
if(pos[i] == 0 && !Q.empty())
{
pos[i] = Q.front(); Q.pop();
ans += R[i] * W[pos[i]];
}
}
}
printf("%d\n", ans);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |