# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
733927 | vjudge1 | Garage (IOI09_garage) | C++98 | 3 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int main()
{
unsigned long long s=0;
int n,m,k=0,p=0,q=0;
cin>>n>>m;
int a[n][2],c[m], l[m*2],w[m];
for(int i=0; i<n; i++)
{
cin>>a[i][0]; a[i][1]=0;
}
for(int j=0; j<m; j++)
cin>>c[j];
int j=0;
for(int i=0; i<m*2; i++)
cin>>l[i];
for(int i=0; i<m*2; i++)
{
if(l[i]>0)
{
if(k>=n)
{
w[p]=l[i]; p++;
}
else{
for(int j=0; j<n; j++)
{
if(a[j][1]==0) {
a[j][1]=l[i]; s+=c[l[i]-1]*a[j][0]; k++; break;
}
}
}
}
else {
int x=abs(l[i]);
for(int j=0; j<n; j++)
{
if(a[j][1]==x) {
if(p>q) {
a[j][1]=w[q]; s+=a[j][0]*c[w[q]-1]; q++;
}
else {
a[j][1]=0; k--;} break;
}
}
}
}
cout<<s;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |