# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
567634 | losmi247 | Garage (IOI09_garage) | C++14 | 2 ms | 356 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<queue>
#define optimizar_io ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
int n, m;
bool P[102];
int pos[2002], cont;
int R[102], W[2002];
int car;
queue<int> Q;
int firstP(){
for( int i = 1; i <= n; i++ )
if( !P[i] )
return i;
}
int main(){
optimizar_io
cin >> n >> m;
for( int i = 1; i <= n; i++ )
cin >> R[i];
for( int i = 1; i <= m; i++ )
cin >> W[i];
cont = n;
int ans = 0;
for( int i = 1; i <= 2 * m; i++ ){
cin >> car;
if( car > 0 ){
if( cont ){
int f = firstP();
cont--; P[f] = true;
ans += R[f] * W[car];
pos[car] = f;
} else {
Q.push( car );
}
} else {
car *= -1;
int f = pos[car];
P[f] = false; cont++;
if( !Q.empty() ){
car = Q.front();
Q.pop();
P[f] = true; cont--;
pos[car] = f;
ans += R[f] * W[car];
}
}
}
cout << ans << "\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |