답안 #535391

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
535391 2022-03-10T06:58:30 Z devariaota Garage (IOI09_garage) C++17
40 / 100
2 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int n, m;
int rate[105];
int weight[2005];
int loc[2005];

int main() {
  cin >> n >> m;
  for(int i = 1; i <= n; i++) {
    cin >> rate[i];
  }
  for(int i = 1; i <= m; i++) {
    cin >> weight[i];
  }
  priority_queue<int, vector<int>, greater<int> > pq;
  for(int i = 1; i <= n; i++) {
    pq.push(i);
  }
  int ans = 0;
  queue<int> q;
  
  for(int i = 1; i <= 2 * m; i++) {
    int a;
    cin >> a;
    if (a > 0) {
      if (!pq.empty()) {
        loc[a] = pq.top();
        ans += weight[a] * rate[loc[a]];
        pq.pop();
      }
      else {
        q.push(a);
      }
    }
    else {
      a *= -1;
      if (!q.empty()) {
        int next = q.front();
        q.pop();
        ans += weight[next] * rate[loc[a]];
      }
      else {
        pq.push(loc[a]);
      }
    }
  }
  cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Correct 0 ms 304 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Correct 1 ms 308 KB Output is correct
6 Incorrect 0 ms 212 KB Output isn't correct
7 Correct 0 ms 212 KB Output is correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Correct 0 ms 212 KB Output is correct
10 Incorrect 1 ms 212 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 316 KB Output is correct
14 Incorrect 1 ms 316 KB Output isn't correct
15 Correct 1 ms 324 KB Output is correct
16 Incorrect 1 ms 212 KB Output isn't correct
17 Incorrect 2 ms 340 KB Output isn't correct
18 Incorrect 2 ms 340 KB Output isn't correct
19 Incorrect 2 ms 348 KB Output isn't correct
20 Incorrect 2 ms 340 KB Output isn't correct