답안 #569411

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
569411 2022-05-27T11:33:17 Z Aurora2005 Garage (IOI09_garage) C++14
40 / 100
2 ms 340 KB
#include<bits/stdc++.h>
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  vector<long long int> R(N);
  for(int i=0;i<N;i++) cin >> R[i];
  vector<long long int> W(M);
  for(int i=0;i<M;i++) cin >> W[i];
  priority_queue<int,vector<int>,greater<int>> que1;
  for(int i=0;i<N;i++) que1.push(i);
  queue<int> que2;
  vector<int> P(M);
  long long int ans = 0;
  for(int i=0;i<2*M;i++){
    int C;
    cin >> C;
    if(C > 0){
      C--;
      if(que1.size() == 0) que2.push(C);
      else{
        int a = que1.top();
        que1.pop();
        ans  += R[a]*W[C];
        P[C] = a;
      }
    }
    else{
      C++;
      C *= -1;
      int a = P[C];
      que1.push(a);
      if(que2.size() > 0){
        int b = que1.top();
        int c = que2.front();
        ans += R[b]*W[c];
        que1.pop();
        que2.pop();
      }
    }
  }
  cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Correct 1 ms 212 KB Output is correct
6 Incorrect 1 ms 304 KB Output isn't correct
7 Correct 1 ms 212 KB Output is correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Correct 1 ms 300 KB Output is correct
10 Incorrect 1 ms 300 KB Output isn't correct
11 Correct 1 ms 212 KB Output is correct
12 Incorrect 1 ms 212 KB Output isn't correct
13 Correct 1 ms 212 KB Output is correct
14 Incorrect 1 ms 212 KB Output isn't correct
15 Correct 1 ms 212 KB Output is correct
16 Incorrect 1 ms 340 KB Output isn't correct
17 Incorrect 2 ms 340 KB Output isn't correct
18 Incorrect 2 ms 316 KB Output isn't correct
19 Incorrect 2 ms 340 KB Output isn't correct
20 Incorrect 2 ms 312 KB Output isn't correct