| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 936604 | Malix | Garage (IOI09_garage) | C++14 | 1 ms | 360 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
//freopen("test_input.txt", "r", stdin);
 //freopen("test_output.txt", "w", stdout);
  int n,m;cin>>n>>m;
  vi r(n);
  REP(i,0,n)cin>>r[i];
  vi w(m+1);
  REP(i,1,m+1)cin>>w[i];
  priority_queue<int, vector<int>, greater<int>> p;
  queue<int> q;
  REP(i,0,n)p.push(i);
  vi arr(m+1);
  int ans=0;int t;
  REP(i,0,2*m){
    cin>>t;
    if(t>0){
      if(p.empty()){
        q.push(t);
      }
      else{
        arr[t]=p.top();
        ans+=r[arr[t]]*w[t];
        p.pop();
      }
    }
    else{
      p.push(arr[-t]);
      if(!q.empty()){
        t=q.front();
        q.pop();
        arr[t]=p.top();
        ans+=r[arr[t]]*w[t];
        p.pop();
      }
    }
  }
  cout<<ans;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
