답안 #879051

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
879051 2023-11-26T07:55:26 Z klee Garage (IOI09_garage) C++14
40 / 100
2 ms 604 KB
#include <bits/stdc++.h>
using namespace std;
vector<int> have(101), where(101);
int main() 
{
  int n,m;
  cin >> n >> m;
  vector<int> price(n+1), weight(m+1);
  for(int i=1;i<=n;i++) cin >> price[i];
  for(int i=1;i<=m;i++) cin >> weight[i];
  int ans=0;
  for(int i=0;i<2*m;i++)
  {
    int x;
    cin >> x;
    if(x>=0)
    {
      for(int j=1;j<=n;j++)
      {
        if(have[j] == 0)
        {
          have[j] = 1;
          ans+= (price[j]*weight[x]);
          // cout << j << 'a' << x << ' ' << price[j] << ' ' << weight[x] << ' ' << price[j]*weight[x] << ' '  << ans << ' ' << '\n';
          where[x] = j;
          break;
        }
      }
    }
    else
    {
      x = abs(x);
      int a = where[x];
      have[a] = 0;
    }
  }
  cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Correct 0 ms 436 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Correct 0 ms 344 KB Output is correct
10 Runtime error 1 ms 348 KB Execution killed with signal 11
11 Correct 0 ms 348 KB Output is correct
12 Incorrect 1 ms 348 KB Output isn't correct
13 Correct 1 ms 348 KB Output is correct
14 Incorrect 1 ms 348 KB Output isn't correct
15 Correct 1 ms 348 KB Output is correct
16 Incorrect 1 ms 348 KB Output isn't correct
17 Runtime error 2 ms 604 KB Execution killed with signal 11
18 Incorrect 1 ms 476 KB Output isn't correct
19 Runtime error 1 ms 604 KB Execution killed with signal 11
20 Incorrect 2 ms 344 KB Output isn't correct