# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
225961 | FieryPhoenix | Garage (IOI09_garage) | C++11 | 7 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
#define INF 2001001001
#define MOD 1000000007
int N,M;
int R[101];
ll ans;
int occ[101];
int W[2001];
int main()
{
//ios_base::sync_with_stdio(0);cin.tie(0);
//freopen (".in","r",stdin);
//freopen (".out","w",stdout);
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;
for (int i=1;i<=M*2;i++){
int X; cin>>X;
if (X>0)
q.push(X);
else{
for (int j=1;j<=N;j++)
if (occ[j]==-X){
occ[j]=0;
break;
}
}
while (!q.empty()){
int spot=-1;
for (int j=1;j<=N;j++)
if (occ[j]==0){
spot=j;
break;
}
if (spot==-1) break;
occ[spot]=q.front();
ans+=W[q.front()]*R[spot];
q.pop();
}
}
cout<<ans<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |